The Date function returns today's date in one of various formats.
| result = Date( [ format ] ) |
Base -- number of complete days since 1 Jan 0001 -- 731022
Days -- julian day of the year -- 173
European -- dd/mm/yy -- 22/06/02 (Unsortable!)
Month -- June
Normal -- 22 Jun 2002 (Default)
Ordered -- yy/mm/dd -- 02/06/22 (Sortable -- unless century boundary is spanned)
Standard -- yyyymmdd -- 20020622 (Sortable!)
USA -- mm/dd/yy -- 06/22/02 (Unsortable!)
Weekday -- Saturday
When the format argument is omitted, the Date function returns the date in the Normal format -- 22 Jun 2002
|
Examples:
say Date( 'S' ) -- shows 20020622
/* this is a simple program
* that displays a calendar and the current date and time
* the current date is bracketed by '>' and '<'
*/
daysin = "31 28 31 30 31 30 31 31 30 31 30 31"
days = "Monday Tuesday Wednesday Thursday Friday Saturday Sunday"
/* get year, month, and day of month */
parse value date(standard) with year 5 month 7 dayOfMonth
/* show title lines */
say right( time(civil), 8) center( date(month), 38 ),
|| substr( year, 3 )"."right( date(dayofyear), 3, '0' )
say center( year, 56 )
say " Sun Mon Tue Wed Thu Fri Sat"
dayofwk = wordpos( date(weekday), days ) /* identify day of week: 1 to 7 */
day1no = 1 + ((dayofwk + (35 - dayOfMonth)) // 7) /* day# of 1st day of month */
daysinmo = word( daysin, month ) /* identify #days in month */
if leap( year ) & (month = 2) then /* identify if this is a leap month */
daysinmo = daysinmo + 1 /* february has 29 days in a leap year */
/* prefix leading line with blanks */
call charout , left( " ", (day1no//7) * 8 )
do i=1 to daysinmo /* show all day numbers within current month */
if i = dayOfMonth then /* day "i" is today's day of month */
call charout , center( "> "right( i, 2 )" <", 8 ) /* highlight today */
else
call charout , center( right( i, 2 ), 8 )
if ((i+day1no) // 7) = 0 then /* saturday */
say /* end line */
end
if ((i+day1no) // 7) <> 1 then /* if last day was not saturday */
say /* end line */
exit 0
/* LEAP procedure
* identify if this year is a leap year (the year 2000 is not a leap year)
*/
leap : procedure
arg year
return (year//4 = 0) & ((year//100 <> 0) | (year//400 = 0)) /* after Pope Gregory */
|