Next Previous Up Top Contents Index

7 The Date Module

7.2 Representing dates and times

The Date module contains a single class, <date>, an instance of which can represent any date between 1 Jan 1800 00:00:00 and 31 Dec 2199 23:59:59, Greenwich Mean Time. You can create a date object by calling the function encode-date or using the make method for <date>.

<date>

Sealed class

The class of all date objects. It is a subclass of <number>. Note that there is no method for make defined on <date>. The function encode-date should be used instead.
make date-class

G.f. method

make date-class #key iso8601-string year month day hours minutes
                   seconds microseconds time-zone-offset 
=> date-instance

Creates an instance of the <date> class.
encode-date

Function

encode-date year month day hours minutes seconds
            #key microseconds time-zone-offset => date

Creates a <date> object from a set of <integer> values.

Each of the arguments to encode-date and to the make method on <date> is an instance of <integer> (except for the iso8601-string keyword for the make method, which is a string) that is passed as an init-keyword value to the <date> object. Each init-keyword takes an instance of <integer>, limited to the natural range for that attribute. For example, month: can only take values between 1 and 12.

You must specify values, via encode-date, for at least the year:, month:, and day: init-keywords. In addition, you can also specify values for hours:, minutes:, seconds:, microseconds:, and time-zone-offset:. If not supplied, the default value for each of these init-keywords is 0.

The time-zone-offset: init-keyword is used to represent time zones in the Date module as <integer> values representing the offset in minutes from Greenwich Mean Time (GMT). Positive values are used for time zones East of Greenwich; negative values represent time zones to the west of Greenwich.

For example, the value -300 (-5 hours) is U.S. Eastern Standard Time and the value -240 (-4 hours) is U.S. Eastern Daylight Savings Time.

If you wish, a <date> can be specified completely by using the iso8601-string: init-keyword. This init-keyword takes an instance of <string>, which should be a valid ISO8601 format date. If you use the iso8601-string: init-keyword, there is no need to specify any other init-keywords to a call to make on <date>.

current-date

Function

current-date () => date

Returns the current date on your local machine as a <date> object.
<day-of-week>

Type

one-of(#"Sunday", #"Monday", #"Tuesday", #"Wednesday",
       #"Thursday", #"Friday", #"Saturday")

Days of the week can be represented using the <day-of-week> type.
You can extract the day of the week of a specified date using date-day-of-week. See Section 7.5 for details.

System and I/O Reference - 31 MAR 2000

Next Previous Up Top Contents Index