Date and time library for Racket
Intended to be a successor to gregor
.
datetime-lib
, likegregor
is meant to be a more featureful replacement for Racket's built-in date and time data structures and functions. Butdatetime-lib
additionally permits its generic functions to work with the built-in data structures. Specifically, thedate
anddate*
structs fromracket/base
that satisfybase-date/compat?
will also satisfydate-provider?
,time-provider?
,datetime-provider?
,utc-offset-provider?
, as well as the relevant*-arithmetic-provider?
predicates.- This library uses a simpler and leaner internal representation. For
example, in
gregor
, adate
struct contains the year, month, and day-of-month (which are contained in their ownymd
struct), in addition to a Julian Day number. The reason for this is that some operations are more efficient when operating on the former, and others when operating on the latter. Indatetime-lib
, however, we just store the year, month, and day. If/when we need the JDN, we compute it on-the-fly. - The
moment
struct fromgregor
is replaced by two different structs:datetime/offset
anddatetime/tz
. The former represents a datetime with a UTC offset; the latter has an IANA time zone. datetime-lib
maintains a stricter type-discipline thangregor
. For example, ingregor
, theperiod-between
function accepts twodatetime-provider?
s as input, which implies that it even makes sense to ask for how much time elapsed between adatetime
and amoment
, even though it does not.- Whereas
gregor
assumes that users will use generics for nearly all operations other than construction,datetime-lib
provides many more struct-specific functions, so that a user can choose to work with generics or not. datetime-lib
will ship with a much more modest formatting and parsing library thangregor
. Interested third parties are welcome (and encouraged) to provide a fully-featured and localized formatting and parsing library. (My current intention for this library is to provide basicstrftime
/strptime
-like functionalty, in addition to some ISO 8601 functionality.)
- Get rid of
period
(as it currently exists) and replace it with two different data structures that replace the current concepts ofdate-period
andtime-period
. An issue in the gregor project has me leaning toward this separation. - I think some functions are currently both in
date.rkt
and inquery.rkt
. I think my intention was to remove them fromdate.rkt
, since they don't actually operate ondate
s. - Revisit the flooring integer division functions in
math.rkt
. Maybe those implementations are ok. They do seem to work, at any rate, but the bitwise operations just seem out of place there. I don't remember where I got that idea from. - Maybe add interval types. The tricky thing here is getting the API
right, since there are some operations that make sense when the
component/witness type is discrete (as with a
date-interval
) vs. when it is continuous or continuous-ish (as with atime-interval
).
- Real UTC support (i.e., support for leap seconds)
- Support for other time scales (e.g., TAI)