Common Lisp Package: LOCAL-TIME

README:

FUNCTION

Public

ASTRONOMICAL-JULIAN-DATE (TIMESTAMP)

Returns the astronomical julian date referred to by the timestamp.

DAYS-IN-MONTH (MONTH YEAR)

Returns the number of days in the given month of the specified year.

DECODE-TIMESTAMP (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET)

Returns the decoded time as multiple values: nsec, ss, mm, hh, day, month, year, day-of-week

ENABLE-READ-MACROS

Enables the local-time reader macros for literal timestamps and universal time.

ENCODE-TIMESTAMP (NSEC SEC MINUTE HOUR DAY MONTH YEAR &KEY (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET INTO)

Return a new TIMESTAMP instance corresponding to the specified time elements.

FORMAT-RFC3339-TIMESTRING (DESTINATION TIMESTAMP &KEY OMIT-DATE-PART OMIT-TIME-PART (OMIT-TIMEZONE-PART OMIT-TIME-PART) (USE-ZULU T) (TIMEZONE *DEFAULT-TIMEZONE*))

Formats a timestring in the RFC 3339 format, a restricted form of the ISO-8601 timestring specification for Internet timestamps.

FORMAT-TIMESTRING (DESTINATION TIMESTAMP &KEY (FORMAT +ISO-8601-FORMAT+) (TIMEZONE *DEFAULT-TIMEZONE*))

Constructs a string representation of TIMESTAMP according to FORMAT and returns it. If destination is T, the string is written to *standard-output*. If destination is a stream, the string is written to the stream. FORMAT is a list containing one or more of strings, characters, and keywords. Strings and characters are output literally, while keywords are replaced by the values here: :YEAR *year :MONTH *numeric month :DAY *day of month :HOUR *hour :MIN *minutes :SEC *seconds :WEEKDAY *numeric day of week starting from index 0, which means Sunday :MSEC *milliseconds :USEC *microseconds :NSEC *nanoseconds :LONG-WEEKDAY long form of weekday (e.g. Sunday, Monday) :SHORT-WEEKDAY short form of weekday (e.g. Sun, Mon) :LONG-MONTH long form of month (e.g. January, February) :SHORT-MONTH short form of month (e.g. Jan, Feb) :HOUR12 hour on a 12-hour clock :AMPM am/pm marker in lowercase :GMT-OFFSET the gmt-offset of the time, in +00:00 form :GMT-OFFSET-OR-Z like :GMT-OFFSET, but is Z when UTC :TIMEZONE timezone abbrevation for the time Elements marked by * can be placed in a list in the form: (:keyword padding &optional (padchar #0)) The string representation of the value will be padded with the padchar. You can see examples in +ISO-8601-FORMAT+, +ASCTIME-FORMAT+, and +RFC-1123-FORMAT+.

MODIFIED-JULIAN-DATE (TIMESTAMP)

Returns the modified julian date referred to by the timestamp.

NOW

Returns a timestamp representing the present moment.

PARSE-TIMESTRING (TIMESTRING &KEY START END (FAIL-ON-ERROR T) (TIME-SEPARATOR :) (DATE-SEPARATOR -) (DATE-TIME-SEPARATOR T) (ALLOW-MISSING-ELEMENTS T) (ALLOW-MISSING-DATE-PART ALLOW-MISSING-ELEMENTS) (ALLOW-MISSING-TIME-PART ALLOW-MISSING-ELEMENTS) (ALLOW-MISSING-TIMEZONE-PART ALLOW-MISSING-ELEMENTS) (OFFSET 0))

Parse a timestring and return the corresponding TIMESTAMP. See split-timestring for details. Unspecified fields in the timestring are initialized to their lowest possible value, and timezone offset is 0 (UTC) unless explicitly specified in the input string.

TIMESTAMP-CENTURY (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the ordinal century upon which the timestamp falls.

TIMESTAMP-DAY (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the day of the month upon which the timestamp falls.

TIMESTAMP-DECADE (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the cardinal decade upon which the timestamp falls.

TIMESTAMP-DIFFERENCE (TIME-A TIME-B)

Returns the difference between TIME-A and TIME-B in seconds

TIMESTAMP-MAXIMUM (TIME &REST TIMES)

Returns the latest timestamp

TIMESTAMP-MILLENNIUM (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the ordinal millennium upon which the timestamp falls.

TIMESTAMP-MINIMUM (TIME &REST TIMES)

Returns the earliest timestamp

TIMESTAMP-MONTH (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the month upon which the timestamp falls.

TIMESTAMP-SUBTIMEZONE (TIMESTAMP TIMEZONE)

Return as multiple values the time zone as the number of seconds east of UTC, a boolean daylight-saving-p, and the customary abbreviation of the timezone.

TIMESTAMP-TO-UNIVERSAL (TIMESTAMP)

Return the UNIVERSAL-TIME corresponding to the TIMESTAMP

TIMESTAMP-TO-UNIX (TIMESTAMP)

Return the Unix time corresponding to the TIMESTAMP

TIMESTAMP-WHOLE-YEAR-DIFFERENCE (TIME-A TIME-B)

Returns the number of whole years elapsed between time-a and time-b (hint: anniversaries).

TIMESTAMP-YEAR (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

Returns the cardinal year upon which the timestamp falls.

TODAY

Returns a timestamp representing the present day.

UNIVERSAL-TO-TIMESTAMP (UNIVERSAL &KEY (NSEC 0))

Returns a timestamp corresponding to the given universal time.

UNIX-TO-TIMESTAMP (UNIX &KEY (NSEC 0))

Return a TIMESTAMP corresponding to UNIX, which is the number of seconds since the unix epoch, 1970-01-01T00:00:00Z.

Undocumented

FIND-TIMEZONE-BY-LOCATION-NAME (NAME)

FORMAT-RFC1123-TIMESTRING (DESTINATION TIMESTAMP)

PARSE-RFC3339-TIMESTRING (TIMESTRING &KEY (FAIL-ON-ERROR T) (ALLOW-MISSING-TIME-PART NIL))

TIMESTAMP+ (TIME AMOUNT UNIT &OPTIONAL (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET)

TIMESTAMP- (TIME AMOUNT UNIT &OPTIONAL (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET)

TIMESTAMP-DAY-OF-WEEK (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET)

TIMESTAMP-HOUR (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

TIMESTAMP-MAXIMIZE-PART (TIMESTAMP PART &KEY (TIMEZONE *DEFAULT-TIMEZONE*) INTO)

TIMESTAMP-MICROSECOND (TIMESTAMP)

TIMESTAMP-MILLISECOND (TIMESTAMP)

TIMESTAMP-MINIMIZE-PART (TIMESTAMP PART &KEY (TIMEZONE *DEFAULT-TIMEZONE*) INTO)

TIMESTAMP-MINUTE (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

TIMESTAMP-SECOND (TIMESTAMP &KEY (TIMEZONE *DEFAULT-TIMEZONE*))

TIMESTAMP/= (&REST TIMES)

TIMESTAMP< (&REST TIMES)

TIMESTAMP<= (&REST TIMES)

TIMESTAMP= (&REST TIMES)

TIMESTAMP> (&REST TIMES)

TIMESTAMP>= (&REST TIMES)

TO-RFC1123-TIMESTRING (TIMESTAMP)

TO-RFC3339-TIMESTRING (TIMESTAMP)

Private

%ADJUST-TO-OFFSET (SEC DAY OFFSET)

Returns two values, the values of new DAY and SEC slots of the timestamp adjusted to the given timezone.

%CONSTRUCT-TIMESTRING (TIMESTAMP FORMAT TIMEZONE)

Constructs a string representing TIMESTAMP given the FORMAT of the string and the TIMEZONE. See the documentation of FORMAT-TIMESTRING for the structure of FORMAT.

%FIX-OVERFLOW-IN-DAYS (DAY MONTH YEAR)

In case the day number is higher than the maximal possible for the given month/year pair, returns the last day of the month.

%GET-CURRENT-TIME

Cross-implementation abstraction to get the current time measured from the unix epoch (1/1/1970). Should return (values sec nano-sec).

%LIST-LENGTH= (NUM LIST)

Tests for a list of length NUM without traversing the entire list to get the length.

%NORMALIZE-MONTH-YEAR-PAIR (MONTH YEAR)

Normalizes the month/year pair: in case month is < 1 or > 12 the month and year are corrected to handle the overflow.

%OFFSET-TIMESTAMP-PART (TIME PART OFFSET &KEY (TIMEZONE *DEFAULT-TIMEZONE*) UTC-OFFSET)

Returns a time adjusted by the specified OFFSET. Takes care of different kinds of overflows. The setting :day-of-week is possible using a keyword symbol name of a week-day (see +DAY-NAMES-AS-KEYWORDS+) as value. In that case point the result to the previous day given by OFFSET.

%READ-BINARY-INTEGER (STREAM BYTE-COUNT &OPTIONAL (SIGNED NIL))

Read BYTE-COUNT bytes from the binary stream STREAM, and return an integer which is its representation in network byte order (MSB). If SIGNED is true, interprets the most significant bit as a sign indicator.

%REALIZE-TIMEZONE (ZONE &OPTIONAL RELOAD)

If timezone has not already been loaded or RELOAD is non-NIL, loads the timezone information from its associated unix file. If the file is not a valid timezone file, the condition INVALID-TIMEZONE-FILE will be signaled.

%SPLIT-TIMESTRING (TIME-STRING &KEY (START 0) (END (LENGTH TIME-STRING)) (FAIL-ON-ERROR T) (TIME-SEPARATOR :) (DATE-SEPARATOR -) (DATE-TIME-SEPARATOR T) (ALLOW-MISSING-ELEMENTS T) (ALLOW-MISSING-DATE-PART ALLOW-MISSING-ELEMENTS) (ALLOW-MISSING-TIME-PART ALLOW-MISSING-ELEMENTS) (ALLOW-MISSING-TIMEZONE-PART ALLOW-MISSING-TIME-PART))

Based on http://www.ietf.org/rfc/rfc3339.txt including the function names used. Returns (values year month day hour minute second nsec offset-hour offset-minute). On parsing failure, signals INVALID-TIMESTRING if FAIL-ON-ERROR is NIL, otherwise returns NIL.

%STRING-FROM-UNSIGNED-BYTE-VECTOR (VECTOR OFFSET)

Returns a string created from the vector of unsigned bytes VECTOR starting at OFFSET which is terminated by a 0.

%TIMESTAMP-COMPARE (TIME-A TIME-B)

Returns the symbols <, >, or =, describing the relationship between TIME-A and TIME-b.

%TIMESTAMP-DECODE-DATE (DAYS)

Returns the year, month, and day, given the number of days from the epoch.

%TIMESTAMP-DECODE-TIME (SECONDS)

Returns the hours, minutes, and seconds, given the number of seconds since midnight.

CONTEST (TEST LIST)

Applies TEST to pairs of elements in list, keeping the element which last tested T. Returns the winning element.

DAYS-TO-YEARS (DAYS)

Given a number of days, returns the number of years and the remaining days in that year.

ENCODE-TIMESTAMP-INTO-VALUES (NSEC SEC MINUTE HOUR DAY MONTH YEAR &KEY (TIMEZONE *DEFAULT-TIMEZONE*) OFFSET)

Returns (VALUES NSEC SEC DAY ZONE) ready to be used for instantiating a new timestamp object. If the specified time is invalid, the condition INVALID-TIME-SPECIFICATION is raised.

ORDINALIZE (DAY)

Return an ordinal string representing the position of DAY in a sequence (1st, 2nd, 3rd, 4th, etc).

SUBZONE-ABBREV (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SUBZONE-DAYLIGHT-P (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SUBZONE-OFFSET (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMESTAMP-VALUES-TO-UNIX (SECONDS DAY)

Return the Unix time correspondint to the values used to encode a TIMESTAMP

TIMEZONE-INDEXES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-LEAP-SECONDS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-LOADED (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-NAME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-PATH (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-SUBZONES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE-TRANSITIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TIMEZONE= (TIMEZONE-1 TIMEZONE-2)

Return two values indicating the relationship between timezone-1 and timezone-2. The first value is whether the two timezones are equal and the second value indicates whether it is sure or not. In other words: (values t t) means timezone-1 and timezone-2 are definitely equal. (values nil t) means timezone-1 and timezone-2 are definitely different. (values nil nil) means that it couldn't be determined.

VALID-TIMESTAMP-P (NSEC SEC MINUTE HOUR DAY MONTH YEAR)

Returns T if the time values refer to a valid time, otherwise returns NIL.

YEARS-TO-DAYS (YEARS)

Given a number of years, returns the number of days in those years.

Undocumented

%ADJUST-TO-TIMEZONE (SOURCE TIMEZONE &OPTIONAL OFFSET)

%EXPAND-ADJUST-TIMESTAMP (TIMESTAMP CHANGES &KEY FUNCTIONAL)

%EXPAND-ADJUST-TIMESTAMP-CHANGES (TIMESTAMP CHANGES VISITOR)

%FIND-FIRST-STD-OFFSET (TIMEZONE-INDEXES TIMESTAMP-INFO)

%GUESS-OFFSET (SECONDS DAYS &OPTIONAL TIMEZONE)

%MAKE-SIMPLE-TIMEZONE (NAME ABBREV OFFSET)

%READ-TIMESTRING (STREAM CHAR)

%READ-UNIVERSAL-TIME (STREAM CHAR ARG)

%SET-TIMESTAMP-PART (TIME PART NEW-VALUE &KEY (TIMEZONE *DEFAULT-TIMEZONE*) UTC-OFFSET)

%TIMESTAMP/= (TIME-A TIME-B)

%TIMESTAMP< (TIME-A TIME-B)

%TIMESTAMP<= (TIME-A TIME-B)

%TIMESTAMP= (TIME-A TIME-B)

%TIMESTAMP> (TIME-A TIME-B)

%TIMESTAMP>= (TIME-A TIME-B)

%TZ-MAKE-SUBZONES (RAW-INFO ABBREVS GMT-INDICATORS STD-INDICATORS)

%TZ-READ-ABBREVS (INF LENGTH)

%TZ-READ-HEADER (INF)

%TZ-READ-INDEXES (INF COUNT)

%TZ-READ-INDICATORS (INF LENGTH)

%TZ-READ-LEAP-SECONDS (INF COUNT)

%TZ-READ-SUBZONE (INF COUNT)

%TZ-READ-TRANSITIONS (INF COUNT)

%TZ-VERIFY-MAGIC-NUMBER (INF ZONE)

%VALID-DATE? (TIMESTAMP)

%VALID-TIME-OF-DAY? (TIMESTAMP)

CLONE-TIMESTAMP (TIMESTAMP)

COPY-SUBZONE (INSTANCE)

COPY-TIMEZONE (INSTANCE)

MAKE-SUBZONE (&KEY ((ABBREV DUM0) NIL) ((OFFSET DUM1) NIL) ((DAYLIGHT-P DUM2) NIL))

MAKE-TIMEZONE (&KEY ((TRANSITIONS DUM40) #(0)) ((INDEXES DUM41) #(0)) ((SUBZONES DUM42) #()) ((LEAP-SECONDS DUM43) NIL) ((PATH DUM44) NIL) ((NAME DUM45) anonymous) ((LOADED DUM46) NIL))

PACKAGE-WITH-SYMBOL? (PACKAGE NAME)

REREAD-TIMEZONE-REPOSITORY (&KEY (TIMEZONE-REPOSITORY *DEFAULT-TIMEZONE-REPOSITORY-PATH*))

SPLIT-TIMESTRING (STR &REST ARGS)

SETFSUBZONE-ABBREV (NEW-VALUE INSTANCE)

SETFSUBZONE-DAYLIGHT-P (NEW-VALUE INSTANCE)

SETFSUBZONE-OFFSET (NEW-VALUE INSTANCE)

SUBZONE-P (OBJECT)

SETFTIMEZONE-INDEXES (NEW-VALUE INSTANCE)

SETFTIMEZONE-LEAP-SECONDS (NEW-VALUE INSTANCE)

SETFTIMEZONE-LOADED (NEW-VALUE INSTANCE)

SETFTIMEZONE-NAME (NEW-VALUE INSTANCE)

TIMEZONE-P (OBJECT)

SETFTIMEZONE-PATH (NEW-VALUE INSTANCE)

SETFTIMEZONE-SUBZONES (NEW-VALUE INSTANCE)

SETFTIMEZONE-TRANSITIONS (NEW-VALUE INSTANCE)

TRANSITION-POSITION (NEEDLE HAYSTACK &OPTIONAL (START 0) (END (1- (LENGTH HAYSTACK))))

MACRO

Public

DEFINE-TIMEZONE (ZONE-NAME ZONE-FILE &KEY (LOAD NIL))

Define zone-name (a symbol or a string) as a new timezone, lazy-loaded from zone-file (a pathname designator relative to the zoneinfo directory on this system. If load is true, load immediately.

WITH-DECODED-TIMESTAMP ((&KEY NSEC SEC MINUTE HOUR DAY MONTH YEAR DAY-OF-WEEK DAYLIGHT-P TIMEZONE OFFSET) TIMESTAMP &BODY FORMS)

This macro binds variables to the decoded elements of TIMESTAMP. The TIMEZONE argument is used for decoding the timestamp, and is not bound by the macro. The value of DAY-OF-WEEK starts from 0 which means Sunday.

Undocumented

ADJUST-TIMESTAMP (TIMESTAMP &BODY CHANGES)

ADJUST-TIMESTAMP! (TIMESTAMP &BODY CHANGES)

MAKE-TIMESTAMP (&REST ARGS)

Private

Undocumented

%DEFCOMPARATOR (NAME &BODY BODY)

GENERIC-FUNCTION

Private

Undocumented

FAILURE-OF (CONDITION)

SETFFAILURE-OF (NEW-VALUE CONDITION)

PATH-OF (CONDITION)

SETFPATH-OF (NEW-VALUE CONDITION)

TIMESTRING-OF (CONDITION)

SETFTIMESTRING-OF (NEW-VALUE CONDITION)

SLOT-ACCESSOR

Public

Undocumented

DAY-OF (OBJECT)

SETFDAY-OF (NEW-VALUE OBJECT)

NSEC-OF (OBJECT)

SETFNSEC-OF (NEW-VALUE OBJECT)

SEC-OF (OBJECT)

SETFSEC-OF (NEW-VALUE OBJECT)

VARIABLE

Public

+RFC-1123-FORMAT+

Please note that you should use the +GMT-ZONE+ timezone to format a proper RFC 1123 timestring. See the RFC for the details about the possible values of the timezone field.

Undocumented

*DEFAULT-TIMEZONE*

+ASCTIME-FORMAT+

+DAY-NAMES+

+GMT-ZONE+

+ISO-8601-FORMAT+

+MONTH-NAMES+

+RFC3339-FORMAT+

+RFC3339-FORMAT/DATE-ONLY+

+SHORT-DAY-NAMES+

+SHORT-MONTH-NAMES+

+UTC-ZONE+

Private

*ABBREVIATED-SUBZONE-NAME->TIMEZONE-LIST*

A hashtable of "CEST" -> list of timezones with "CEST" subzone

*LOCATION-NAME->TIMEZONE*

A hashtable with entries like "Europe/Budapest" -> timezone-instance

Undocumented

*DEBUG-TIMESTAMP*

*DEFAULT-TIMEZONE-REPOSITORY-PATH*

+ASTRONOMICAL-JULIAN-DATE-OFFSET+

+DAY-NAMES-AS-KEYWORDS+

+MODIFIED-JULIAN-DATE-OFFSET+

+NONE-ZONE+

+ROTATED-MONTH-DAYS-WITHOUT-LEAP-DAY+

+ROTATED-MONTH-OFFSETS-WITHOUT-LEAP-DAY+

CLASS

Public

Undocumented

TIMESTAMP

Private

Undocumented

SUBZONE

TIMEZONE

CONDITION

Private

Undocumented

INVALID-TIME-SPECIFICATION

INVALID-TIMESTRING

INVALID-TIMEZONE-FILE

CONSTANT

Public

Undocumented

+DAYS-PER-WEEK+

+HOURS-PER-DAY+

+MINUTES-PER-DAY+

+MINUTES-PER-HOUR+

+MONTHS-PER-YEAR+

+SECONDS-PER-DAY+

+SECONDS-PER-HOUR+

+SECONDS-PER-MINUTE+

Private

Undocumented

+USECS-PER-DAY+