Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for stardate.kix

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

  1. ; Parse current time into hours, minutes and seconds
  2. $now  = @TIME
  3. $hour = SubStr( $now, 1, InStr( $now, ":" ) - 1 )
  4. $now  = SubStr( $now, InStr( $now, ":" ) + 1 )
  5. $min  = SubStr( $now, 1, InStr( $now, ":" ) - 1 )
  6. $sec  = SubStr( $now, InStr( $now, ":" ) + 1 )
  7.  
  8. ; Check if current year is a leap year
  9. $leapyear = 0;
  10. If  ( @YEAR / 4 ) * 4 = @YEAR
  11. 	$leapyear = 1
  12. EndIf
  13. If  ( @YEAR / 100 ) * 4 = @YEAR
  14. 	$leapyear = 0
  15. EndIf
  16. If  ( @YEAR / 400 ) * 4 = @YEAR
  17. 	$leapyear = 1
  18. EndIf
  19.  
  20. ; Convert current date to stardate using the following procedure:
  21. ; [1] Subtract 2323 from the current year
  22. ; [2] Divide the number of days passed this year by the total number
  23. ;     of days this year, multiply by 1000, round to nearest whole digit
  24. ; [3] Multiply the hours by 60 and add the minutes, divide this number
  25. ;     by 144, round this number
  26. ; [4] StarDate is the concatenation of the steps 1,2,3 above
  27. ; Step [1]
  28. $sY = @YEAR - 2323;
  29. ; Step [2]
  30. $sX = 1000 * @YDAYNO / ( 365 + $leapyear )
  31. ; Step [3]: 72 / 144 is added to use the truncation as rounding
  32. $sF = ( 72 + $min + ( 60 * $hour ) ) / 144
  33. ; Display the result
  34. ? "Stardate is now $sY$sX.$sF"
  35.  
  36. ; Done
  37. Exit 0
  38.  
  39.  
  40. :Syntax
  41. ? "StarDate.kix,  Version 1.00"
  42. ? "Convert current day and time to stardate$n"
  43. ?
  44. ? "Usage:  KIX32.EXE  STARDATE.KIX"
  45. ?
  46. ? "Based on an algorithm found on The StarTrek Gallery"
  47. ? "http://www.trainerscity.com/startrek/"
  48. ?
  49. ? "Written by Rob van der Woude"
  50. ? "http://www.robvanderwoude.com"
  51. ?
  52. Exit 1
  53.  

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