mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-16 16:44:05 +00:00
6e01fc8dce
Added new _STRCMP and _STRICMP commands for quick string comparisons. Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders. Altered UCASE and LCASE routines to be faster in some situations for us.
71 lines
No EOL
2.7 KiB
Text
71 lines
No EOL
2.7 KiB
Text
The '''DATE$''' Function returns the present computer date as a string in a month, day and 4 digit year format.
|
|
|
|
|
|
:::::''Syntax:'' today$ = DATE$
|
|
|
|
|
|
* Returns the present computer date in a mm-dd-yyyy format such as: "12-25-2009"
|
|
* Returns "-" (dash) separators between month, day and year on most machines.
|
|
* '''NOTE''': Older computers may just use the last two digit years!
|
|
|
|
|
|
''Example:'' Displaying the weekday and current date.
|
|
{{CodeStart}} '' ''
|
|
{{Cl|PRINT}} {{Cl|DATE$}}
|
|
month$ = {{Cl|LEFT$}}({{Cl|DATE$}}, 2): M = {{Cl|VAL}}(month$)
|
|
day$ = {{Cl|MID$}}({{Cl|DATE$}}, 4, 2): D = {{Cl|VAL}}(day$)
|
|
day$ = {{Cl|STR$}}(D) ' eliminate any leading zeros
|
|
year$ = {{Cl|RIGHT$}}({{Cl|DATE$}}, 4): Y = {{Cl|VAL}}(year$)
|
|
{{Cl|SELECT CASE}} M
|
|
{{Cl|CASE}} 1: Moon$ = "January"
|
|
{{Cl|CASE}} 2: Moon$ = "February"
|
|
{{Cl|CASE}} 3: Moon$ = "March"
|
|
{{Cl|CASE}} 4: Moon$ = "April"
|
|
{{Cl|CASE}} 5: Moon$ = "May"
|
|
{{Cl|CASE}} 6: Moon$ = "June"
|
|
{{Cl|CASE}} 7: Moon$ = "July"
|
|
{{Cl|CASE}} 8: Moon$ = "August"
|
|
{{Cl|CASE}} 9: Moon$ = "September"
|
|
{{Cl|CASE}} 10: Moon$ = "October"
|
|
{{Cl|CASE}} 11: Moon$ = "November"
|
|
{{Cl|CASE}} 12: Moon$ = "December"
|
|
{{Cl|END SELECT}}
|
|
{{Cl|PRINT}} "Today is " + WeekDay$(M, D, Y) + ", " + Moon$ + day$ + ", " + year$ + {{Cl|SPACE$}}(10)
|
|
|
|
{{Cl|FUNCTION}} WeekDay$ (M, D, Y)
|
|
{{Cl|IF}} M < 3 {{Cl|THEN}} M = M + 12: Y = Y - 1 'add 12 to Jan - Feb month, -1 year
|
|
C = Y \ 100: Y = Y {{Cl|MOD}} 100 'split century and year number
|
|
S1 = (C \ 4) - (2 * C) - 1 'century leap
|
|
S2 = (5 * Y) \ 4 '4 year leap
|
|
S3 = 26 * (M + 1) \ 10 'days in months
|
|
WkDay = (S1 + S2 + S3 + D) {{Cl|MOD}} 7 'weekday total remainder
|
|
{{Cl|IF}} WkDay < 0 {{Cl|THEN}} WkDay = WkDay + 7 'Adjust negative results to 0 to 6
|
|
{{Cl|SELECT CASE}} WkDay
|
|
{{Cl|CASE}} 0: day$ = "Sunday"
|
|
{{Cl|CASE}} 1: day$ = "Monday"
|
|
{{Cl|CASE}} 2: day$ = "Tuesday"
|
|
{{Cl|CASE}} 3: day$ = "Wednesday"
|
|
{{Cl|CASE}} 4: day$ = "Thursday"
|
|
{{Cl|CASE}} 5: day$ = "Friday"
|
|
{{Cl|CASE}} 6: day$ = "Saturday"
|
|
{{Cl|END SELECT}}
|
|
WeekDay$ = day$
|
|
{{Cl|END FUNCTION}} '' ''
|
|
{{CodeEnd}}
|
|
{{small|Code by Ted Weissgerber}}
|
|
{{OutputStart}}
|
|
06-02-2010
|
|
Today is Wednesday, June 2, 2010
|
|
{{OutputEnd}}
|
|
:'''NOTE:''' When using {{KW|DEFINT}} A-Z in the main program, place DEFINT A-Z before FUNCTION WeekDay$ line.
|
|
|
|
|
|
''See also:''
|
|
|
|
* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]]
|
|
|
|
* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]]
|
|
|
|
|
|
|
|
{{PageNavigation}} |