Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for stardate.rex

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

  1. /* Convert current date and time to stardate */
  2.  
  3. If Arg( 1, "E" ) Then Do
  4. 	Say
  5. 	Say "StarDate.rex,  Version 1.00"
  6. 	Say "Convert current date and time to stardate"
  7. 	Say
  8. 	Say "Usage:  <REXX>  STARDATE.REX"
  9. 	Say
  10. 	Say 'Where:  "<REXX>" is your Rexx interpreter:'
  11. 	Say "              - Windows:  REGINA.EXE or REXX.EXE, whichever is installed"
  12. 	Say "              - OS/2:     no need to specify, just rename script to *.cmd"
  13. 	Say
  14. 	Say "Based on an algorithm found on The StarTrek Gallery"
  15. 	Say "http://www.trainerscity.com/startrek/"
  16. 	Say
  17. 	Say "Written by Rob van der Woude"
  18. 	Say "http://www.robvanderwoude.com"
  19. 	Say
  20. End
  21.  
  22. /* Current year */
  23. year = Left( Date( "S" ), 4 )
  24.  
  25. /* Calculate fraction of current year */
  26. ydays = Date( "D" )
  27.  
  28. /* Check for leap year */
  29. leapyear = 0
  30. If ( year //   4 ) = 0 Then leapyear = 1
  31. If ( year // 100 ) = 0 Then leapyear = 0
  32. If ( year // 400 ) = 0 Then leapyear = 1
  33.  
  34. /* Calculate actual starsate */
  35. stardate = ( year - 2323 )||1000 * ydays % ( 365 + leapyear )||"."||Time( "M" ) % 144
  36.  
  37. /* Display the result */
  38. Say
  39. Say "Stardate today is "||stardate
  40.  

page last modified: 2024-04-16; loaded in 0.0060 seconds