On this page:
9.0
top
up

2DatesπŸ”— i

Gregor provides a date struct that represents a calendar date without a time or time zone. Unfortunately, the name date conflicts with an existing, incompatible definition in racket/base.

The author of this package considered other names, including Date (with a capital D) and local-date (à la Joda-Time) but in the end decided to live with the incompatibility. Gregor’s date , along with its companion data structures (time , datetime , and moment ) should be considered a replacement of, not a supplement to, the built-in Racket date.

procedure

( date year[monthday])date?

month:(integer-in 112)=1
day:(day-of-month/c yearmonth)=1
Constructs a date with the given year, month, and day.

Examples:
> (date 1941127)

#<date 1941εΉ΄12月07ζ—₯>

> (date 19657)

#<date 1965εΉ΄07月01ζ—₯>

> (date 1970)

#<date 1970εΉ΄01月01ζ—₯>

procedure

( date? x)boolean?

x:any/c
Returns #t if x is a date ; #f otherwise.

procedure

( jdn->date jdn)date?

Returns the date corresponding to the given Julian day number, which is the number of solar days that have elapsed since 12:00 UT on November 24, 4714 BC in the proleptic Gregorian calendar.

Examples:
> (jdn->date 0)

#<date -4713εΉ΄11月24ζ—₯>

> (jdn->date 2440588)

#<date 1970εΉ΄01月01ζ—₯>

procedure

( date->iso8601 d)string?

d:date?
Returns an ISO 8601 string representation of d.

Examples:
> (date->iso8601 (date 1941127))

"1941-12-07"

> (date->iso8601 (date 19657))

"1965-07-01"

> (date->iso8601 (date 1970))

"1970-01-01"

procedure

( date=? xy)boolean?

x:date?
y:date?

procedure

( date<? xy)boolean?

x:date?
y:date?

procedure

( date<=? xy)boolean?

x:date?
y:date?

procedure

( date>? xy)boolean?

x:date?
y:date?

procedure

( date>=? xy)boolean?

x:date?
y:date?
Comparison functions on dates.

Examples:
> (date=? (date 1970)(date 197011))

#t

> (date<? (date 1941127)(date 19657))

#t

> (date>? (date 1492)(date 2015))

#f

An order defined on dates.

Examples:
> (date-order (date 1970)(date 197011))

'=

> (date-order (date 1941127)(date 19657))

'<

> (date-order (date 2015)(date 1492))

'>

#<splay-tree*>

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /