//--------------------------------------------------------------------------------- // &V[mydate] is a given date in external format like dd.mm.yyyy or mm/dd/yyyy //--------------------------------------------------------------------------------- // GuiXT uses the following rules for handling dates in computations, or comparisons with < or >: // // (1) A date in one of the 6 external date formats is automatically converted to an absolute number // of days, before doing the calculation or comparison // // (2) If one adds or subtracts a number to/from a date, the result is formatted as a date again, using the // same date format as the given date // Get date in format dd.mm.yyyy, to avoid handling all different date formats Set V[reldate] "&V[mydate]" - "01.01.1000" Set V[date] "01.01.1000" + "&V[reldate]" Set V[year] "&V[date](7-10)" label compute_week // Get start of 1st week Set V[firstweek] "01.01.&V[year]" / 7 decimals=0 Set V[firstweek] "&V[firstweek]" * 7 // Get week number Set V[week] "&V[date]" * 1 Set V[week] "&V[week]" - "&V[firstweek]" Set V[week] "&V[week]" + 4 Set V[week] "&V[week]" / 7 decimals=0 // Last week of previous year? (can be 52 or 53) if V[week=0] Set V[year] "&V[year]" - 1 Set V[date] "31.12.&V[year]" goto compute_week endif // ... or first week of following year? if V[week=53] Set V[lastweek] "&V[firstweek]" + 364 if V[lastweek>28.12.&V[year]] Set V[year] "&V[year]" + 1 Set V[week] 1 endif endif //--------------------------------------------------------------------------------- // &V[year] &V[week] // are now the year and week corresponding to the given date &V[mydate] //---------------------------------------------------------------------------------