home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / timevent / taskmstr / showdate.tsk < prev    next >
Encoding:
Text File  |  1995-05-07  |  1.7 KB  |  58 lines

  1. // This task identifies which weekday of the month it is (i.e.,
  2. // 1st/2nd/3rd/4th/5th  Monday/Tuesday/.../Saturday/Sunday) and
  3. // whether it is the last occurrence of that day for the month
  4.  
  5. // Variables used:
  6. //
  7. //   %0 : Used to calculate the occurrence count (dec %DAY% until less than 7)
  8. //   %1 : Used to calculate the week of the month (1 - 5)
  9. //   %2 : Week descriptor (cosmetic)
  10.  
  11. DEFINE %0 %DAY%
  12. DEFINE %1 1
  13.  
  14.  
  15. // Calculate the week number
  16.  
  17. WHILE %0>07
  18.     DEFINE %0 %0-=07
  19.     DEFINE %1 %1+=1
  20. LOOP
  21.  
  22.  
  23. // Define the week number descriptor according to the previous loop calculation
  24.  
  25. IF %1==1                                                        // 1st occur
  26.     DEFINE %2 1st
  27. ELSEIF %1==2                                                    // 2nd occur
  28.     DEFINE %2 2nd
  29. ELSEIF %1==3                                                    // 3rd occur
  30.     DEFINE %2 3rd
  31. ELSEIF %1==4                                                    // 4th occur
  32.     DEFINE %2 4th
  33. ELSE                                                            // must be 5th
  34.     DEFINE %2 5th
  35. ENDIF
  36.  
  37.  
  38. // Echo the results of the calculation & test
  39.  
  40. ECHO Today (%MONTH%/%DAY%) is the %2 %DAY_OF_WEEK% in %MONTH_NAME%
  41.  
  42.  
  43. // Set %1 to maximum possible days for this month less 7 (for last week)
  44.  
  45. IF %MONTH%==02                                                  // Feb = 28
  46.     DEFINE %1 21
  47. ELSEIF %MONTH%==04 OR %MONTH%==06 OR %MONTH%==09 OR %MONTH%==11 // these = 30
  48.     DEFINE %1 23
  49. ELSE                                                            // rest = 31
  50.     DEFINE %1 24
  51. ENDIF
  52.  
  53.  
  54. // Check if last %DAY_OF%WEEK% for this month
  55.  
  56. IF %DAY%>%1 THEN ECHO (Note: It is also the last %DAY_OF_WEEK% in %MONTH_NAME%)
  57.  
  58.