Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for tomorrow.kix

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

  1. ; Tomorrow.kix,  Version 1.10
  2. ; Display today's and tomorrow's date in two formats
  3. ; Written by Rob van der Woude
  4. ; http://www.robvanderwoude.com
  5.  
  6. ; Today's date in YYYYMMDD format
  7. $SortDate = ( 10000 * @YEAR ) + ( 100 * @MONTHNO ) + @MDAYNO
  8.  
  9. ; Calculate tomorrow's date
  10. $TomorD = @MDAYNO + 1
  11. $TomorM = @MONTHNO
  12. $TomorY = @YEAR
  13.  
  14. ; It gets tricky when today is the last day of the month
  15. ; Thanks for Michael Kahle for correcting an error in the leapyear code
  16. If @MDAYNO > 27
  17. 	Select
  18. 		Case @MONTHNO = 1 ; January
  19. 			If @MDAYNO = 31
  20. 				$TomorD = 1
  21. 				$TomorM = 2
  22. 			EndIf
  23. 		Case @MONTHNO = 2 ; February
  24. 			If @MDAYNO = 29
  25. 				$TomorD = 1
  26. 				$TomorM = 3
  27. 			Else
  28. 				If @MDAYNO = 28
  29. 					$LeapYear = 0
  30. 					If ( @YEAR / 4 ) * 4 = @YEAR
  31. 						$LeapYear = 1
  32. 					EndIf
  33. 					If ( @YEAR / 100 ) * 100 = @YEAR
  34. 						$LeapYear = 0
  35. 					EndIf
  36. 					If ( @YEAR / 400 ) * 400 = @YEAR
  37. 						$LeapYear = 1
  38. 					EndIf
  39. 					If $LeapYear = 0
  40. 						$TomorD = 1
  41. 						$TomorM = 3
  42. 					EndIf
  43. 				EndIf
  44. 			EndIf
  45. 		Case @MONTHNO = 3 ; March
  46. 			If @MDAYNO = 31
  47. 				$TomorD = 1
  48. 				$TomorM = 4
  49. 			EndIf
  50. 		Case @MONTHNO = 4 ; April
  51. 			If @MDAYNO = 30
  52. 				$TomorD = 1
  53. 				$TomorM = 5
  54. 			EndIf
  55. 		Case @MONTHNO = 5 ; May
  56. 			If @MDAYNO = 31
  57. 				$TomorD = 1
  58. 				$TomorM = 6
  59. 			EndIf
  60. 		Case @MONTHNO = 6 ; June
  61. 			If @MDAYNO = 30
  62. 				$TomorD = 1
  63. 				$TomorM = 7
  64. 			EndIf
  65. 		Case @MONTHNO = 7 ; July
  66. 			If @MDAYNO = 31
  67. 				$TomorD = 1
  68. 				$TomorM = 8
  69. 			EndIf
  70. 		Case @MONTHNO = 8 ; August
  71. 			If @MDAYNO = 31
  72. 				$TomorD = 1
  73. 				$TomorM = 9
  74. 			EndIf
  75. 		Case @MONTHNO = 9 ; September
  76. 			If @MDAYNO = 30
  77. 				$TomorD = 1
  78. 				$TomorM = 10
  79. 			EndIf
  80. 		Case @MONTHNO = 10 ; October
  81. 			If @MDAYNO = 31
  82. 				$TomorD = 1
  83. 				$TomorM = 11
  84. 			EndIf
  85. 		Case @MONTHNO = 11 ; November
  86. 			If @MDAYNO = 30
  87. 				$TomorD = 1
  88. 				$TomorM = 12
  89. 			EndIf
  90. 		Case @MONTHNO = 12 ; December
  91. 			If @MDAYNO = 31
  92. 				$TomorD = 1
  93. 				$TomorM = 1
  94. 				$TomorY = $TomorY + 1
  95. 			EndIf
  96. 	EndSelect
  97. EndIf
  98.  
  99. ; Tomorrow's date in YYYYMMDD format
  100. $SortTomor = ( 10000 * $TomorY ) + ( 100 * $TomorM ) + $TomorD
  101.  
  102. If $TomorD < 10
  103. 	$TomorD = "0" + $TomorD
  104. EndIf
  105. If $TomorM < 10
  106. 	$TomorM = "0" + $TomorM
  107. EndIf
  108.  
  109. ; Display the results
  110. ? "Format:     YYYYMMDD  (DD/MM/YYYY)"
  111. ? "=================================="
  112. ? "Today:      $SortDate  (@MDAYNO/@MONTHNO/@YEAR)"
  113. ? "Tomorrow:   $SortTomor  ($TomorD/$TomorM/$TomorY)"
  114. ?
  115.  
  116. ; Done
  117. Exit
  118.  

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