1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/DATE$.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

72 lines
2.3 KiB
Plaintext

The [[DATE$]] function returns the current computer date as a string in the format "mm-dd-yyyy".
{{PageSyntax}}
: {{Parameter|today$}} = [[DATE$]]
{{PageDescription}}
* Returns the current computer date in the format "mm-dd-yyyy" (e.g., "12-25-2009").
{{PageExamples}}
''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|DEFINT}} A-Z
{{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}}
{{PageSeeAlso}}
* [[DATE$ (statement)]], [[TIME$]], [[TIME$ (statement)]]
* [[VAL]], [[STR$]], [[MID$]], [[LEFT$]], [[IF...THEN]]
{{PageNavigation}}
<