datelib
The library counts dates as days since 1 January 1978, the day
AmigaOS counts from. SystemDate gives today’s number, Date$ turns a
number into a string such as 24/12/1993, and NumDays turns such a
string back into a number, so that two dates can be compared or
subtracted. DateFormat chooses whether the day or the month comes
first. After Date$, Days, Months, Years and WeekDay give the
parts of that date; after Hours, Mins and Secs give the time.
d$=Date$(SystemDate)
NPrint "Today is ",d$,", day ",WeekDay," of the week"
NPrint "It is ",Hours,":",Mins
NPrint NumDays("24/12/1993")-NumDays("1/1/1993")," days"Dates follow the Gregorian calendar, as the dates of AmigaDOS do, for the years 0 to 9999.
NumDays takes the year as written, so a date string needs the full
year: "24/12/93" is a date in the year 93, not in 1993.
Based on the datelib guide by Acid Software.
Library number 78.
Commands
Date$
The date of day number days (days since 1 January 1978) as a string, dd/mm/yyyy or, after DateFormat 1, mm/dd/yyyy. It also keeps the day, month, year and weekday for Days, Months, Years and WeekDay.
Function, result $. Help text: days.l ;converts days since 1/1/1978 to date string
Arguments: .l
DateFormat
The format of the date strings of Date$ and NumDays, 0 for dd/mm/yyyy (the start value) or 1 for mm/dd/yyyy.
Statement. Help text: 0=dd/mm/yyyy 1=mm/dd/yyyy
Arguments: .w
Days
The day of the month of the last Date$.
Function, result .w. Help text: ;returns day calculated in last call to date$
No arguments.
Hours
Reads the time from the system clock and returns the hour, from 0 to 23. It also keeps the minutes and seconds for Mins and Secs.
Function, result .w. Help text: ;gets system time and returns hour of day
No arguments.
Mins
The minutes of the time read by the last Hours.
Function, result .w. Help text: ;returns minutes calculated at last call to hour
No arguments.
Months
The month, from 1 to 12, of the last Date$.
Function, result .w. Help text: ;returns month calculated in last call to date$
No arguments.
NumDays
The day number (days since 1 January 1978) of a date string in the format DateFormat set, dd/mm/yyyy at the start. Day and month have one or two digits, the year up to four.
Function, result .l. Help text: date$ ;converts dd/mm/yyyy to days since 1/1/1978
Arguments: $
A year is taken as written: "1/1/78" is the year 78, not 1978. A
date string that cannot be read, such as one with an empty field or a
month outside 1 to 12, gives 0, which is also the number of 1 January
1978.
Secs
The seconds of the time read by the last Hours.
Function, result .w. Help text: ;returns seconds calculated at last call to hour
No arguments.
SystemDate
Today’s date from the system clock, as the number of days since 1 January 1978.
Function, result .l. Help text: Returns system date as number of days since 1/1/1978
No arguments.
WeekDay
The day of the week of the last Date$, 0 for Sunday to 6 for Saturday.
Function, result .w. Help text: ;returns day of week calculated in last call to date$
No arguments.
Years
The year of the last Date$.
Function, result .w. Help text: ;returns year calculated in last call to date$
No arguments.