Common Lisp Package: SIMPLE-DATE

README:

FUNCTION

Public

DAY-OF-WEEK (DATE)

Returns the weekday of the given date as a number between 0 and 6, 0 being Sunday and 6 being Saturday.

DECODE-DATE (DATE)

Get the date elements from a date object.

DECODE-TIMESTAMP (TIMESTAMP)

Extract the date and time from a timestamp object.

ENCODE-DATE (YEAR MONTH DAY)

Create a date object.

ENCODE-INTERVAL (&KEY (YEAR 0) (MONTH 0) (WEEK 0) (DAY 0) (HOUR 0) (MINUTE 0) (SECOND 0) (MILLISECOND 0))

Create an interval object. Parameters may be negative.

ENCODE-TIMESTAMP (YEAR MONTH DAY &OPTIONAL (HOUR 0) (MINUTE 0) (SECOND 0) (MILLISECOND 0))

Create a timestamp object.

TIME<= (A B)

Compare two time-related values, returns a boolean indicating whether the first is less or equal than the second.

TIME>= (A B)

Compare two time-related values, returns a boolean indicating whether the first is greater or equal than the second.

TIMESTAMP-TO-UNIVERSAL-TIME (TIMESTAMP)

Convert a timestamp to a Lisp universal time.

UNIVERSAL-TIME-TO-TIMESTAMP (UTIME)

Convert a Lisp universal time to a timestamp.

Undocumented

DECODE-INTERVAL (INTERVAL)

Private

DATE-ADD (BASE-DAYS MONTHS)

Add a number of months to a date (expressed in days).

DAYS-BEFORE-MONTH (MONTH)

Find the amount of days in a year before the start of a given month. (This works because in the internal representation march is the first month, so leap days only happen at the end of the year.)

DAYS-IN-MONTH (MONTH YEAR)

Days in a certain month -- note that these months use internal encoding.

DECODE-DAYS (DAYS)

Transform a number of days since March 1st 2000 to a date (in internal format.)

DECODE-MILLISECS (MILLISECS)

Decompose a number of milliseconds into hours, minutes, seconds and milliseconds.

ENCODE-DAYS (YEAR MONTH DAY)

Get the number of days since March 1st 2000 for a given date (in internal format.)

ENCODE-MILLISECS (HOUR MINUTE SECOND MILLISECOND)

Get the amount of milliseconds from a number of bigger units.

INVERT-INTERVAL (INTERVAL)

Invert the components of an interval.

LEAP-YEAR-P (YEAR)

Is this year a leap year?

MONTH-AT-DAY (DAYS)

Find the month in which a given day of the year falls. It's a manually constructed binary search. Which is pretty ugly.

NORMALIZE-TIMESTAMP (DAYS MILLISECS)

Make sure that a number of milliseconds falls within a day, correct the amount of days if necessary.

TO-EXTERNAL-DATE (YEAR MONTH DAY)

Convert a internal date representation to an external one. Internally, months and days start at 0 and the 1st of March 2000 is the year 0.

TO-INTERNAL-DATE (YEAR MONTH DAY)

Convert an external date representation to an internal one.

GENERIC-FUNCTION

Public

TIME-ADD (A B)

Generic function for combining datetime objects. Adding an interval to a date or timestamp will return a new date or timestamp, increased by the value of the interval. Adding two intervals returns a new interval with the sum of the two arguments. Integers can be used in place of intervals, and will be interpreted as an amount of milliseconds.

TIME-SUBTRACT (A B)

Subtracts datetime objects from each other. Subtracting two dates or timestamps results in an interval that represents the difference between them. Similarly subtracting two intervals gives their difference.

TIME< (A B)

Compare two time-related values, returns a boolean indicating whether the first is less than the second.

TIME= (A B)

Compare two time-related values, returns a boolean indicating whether they denote the same time or period.

TIME> (A B)

Compare two time-related values, returns a boolean indicating whether the first is greater than the second.

SLOT-ACCESSOR

Private

Undocumented

DAYS (OBJECT)

SETFDAYS (NEW-VALUE OBJECT)

MILLISECS (OBJECT)

SETFMILLISECS (NEW-VALUE OBJECT)

MONTHS (OBJECT)

SETFMONTHS (NEW-VALUE OBJECT)

CLASS

Public

DATE

This class is used to represent dates where the time of day is not important.

INTERVAL

Intervals can be added to date and timestamp units to get relative times. The amount of time added for the month part of a timestamp depends on the time it is being added to.

TIMESTAMP

A timestamp specifies a time with a precision up to milliseconds.

CONSTANT

Private

Undocumented

+DAYS-IN-100-YEARS+

+DAYS-IN-4-YEARS+

+DAYS-IN-400-YEARS+

+DAYS-IN-YEAR+

+MILLISECS-IN-DAY+

+POSTGRES-DAY-OFFSET+

+UNIVERSAL-TIME-OFFSET+

+USECS-IN-ONE-DAY+