Date structureThe Date structure provides functions for converting between times and dates, and formatting and scanning dates.
signature DATE
structure Date : DATE
datatype weekday
= Mon
| Tue
| Wed
| Thu
| Fri
| Sat
| Sun
datatype month
= Jan
| Feb
| Mar
| Apr
| May
| Jun
| Jul
| Aug
| Sep
| Oct
| Nov
| Dec
datatype date
= DATE of {year : int, month : month, day : int, hour : int, minute : int, second : int, wday : weekday option, yday : int option, isDst : bool option}
exception Date
val fromTime : Time.time -> date
val fromUTC : Time.time -> date
val toTime : date -> Time.time
val toString : date -> string
val fmt : string -> date -> string
val fromString : string -> date option
val scan : (char, 'a) StringCvt.reader -> 'a -> (date, 'a) option
val compare : (date * date) -> order
datatype weekday
datatype month
datatype date
exception Date
fromTime t
fromUTC t
toTime date
The weekday of a given date date can be computed as #wday(fromTime(toTime date)); yday and, if possible, isDst can be handled similarly.
toString date
"Wed Mar 08 19:06:45 1995"
It ignores the weekday (if supplied) and recomputes it on the basis of the other fields; the result may be wrong if the date is outside the representable Time.time range. Raises Date if the given date is invalid.
fmt s date
fmt "%A" date returns the full name of the weekday, such as "Monday", for the given date. For a full description of the fmt syntax, consult a description of strftime. As with toString, it ignores the weekday field (if supplied) and recomputes it on the basis of the other fields; the result may be wrong if the date is outside the representable Time.time range. !
Raises Date if the given date is invalid.
fromString s
scan getc str
The function fromString takes a string s as its source of characters. Note that the function fromString is equivalent to StringCvt.scanString scan.
The function scan takes a character stream reader getc and a stream strm. In case of success, it returns SOME(date, rst), where date is the scanned date and rst is the remainder of the stream. The type of scan can also be written as
(char, 'a) StringCvt.reader -> (date, 'a) StringCvt.reader
compare (date1, date2)
StringCvt, Time
Last Modified May 15, 1996
Copyright © 1996 AT&T