Powered by GeSHi

Source code for week.rex

(view source code of week.rex as plain text)

  1. /* Week.cmd,  Version 2.00        */
  2. /* Display week number using Rexx */
  3. /* Written by Rob van der Woude   */
  4. /* http://www.robvanderwoude.com  */
  5.  
  6. /* Translate day of week to number */
  7. select
  8. 	when date( "W" ) = "Saturday"  then ndow = 6
  9. 	when date( "W" ) = "Friday"    then ndow = 5
  10. 	when date( "W" ) = "Thursday"  then ndow = 4
  11. 	when date( "W" ) = "Wednesday" then ndow = 3
  12. 	when date( "W" ) = "Tuesday"   then ndow = 2
  13. 	when date( "W" ) = "Monday"    then ndow = 1
  14. 	otherwise ndow = 0
  15. end
  16.  
  17. /* Calculate number of WHOLE weeks this year (Sundays to Saturdays) */
  18. weeks = ( date( "D" ) - ndow ) % 7
  19.  
  20. /* Add one more if today isn't Saturday */
  21. if ndow < 6 then weeks = weeks + 1
  22.  
  23. /* Display the result */
  24. say
  25. say "Week "||weeks
  26.