Common Lisp Package: QUUX-TIME

README:

FUNCTION

Private

%DAYS-PER-FEBRUARY-YEAR (YEAR)

Return the number of days in February of the given year For example: 1900 --> 28 days.

%DAYS-UNTIL-MONTH (MONTH YEAR)

Return the number of days preceding the given month in the given year. For example: March, 2004 --> (3 2004) --> 60 days

%DAYS-UNTIL-YEAR-MONTH (YEAR MONTH)

Return the number of days since the lisp epoch which precede the given (year, month). For example: (1900 2) --> 31 days.

%YEAR-FROM-2DIGIT-YEAR (2DIGIT-YEAR)

Convert an ambiguous 2-digit year into an unambiguous 4+-digit year. Years before '70 are assumed to be in the 2000's. '70 and later are assumed to be in the 1900's. This function doesn't check that input *is* a 2-digit year.

ADVANCE-TO-NEXT-DAY-OF-WEEK (TIME WEEKDAY &KEY KEEP-TOFD-P)

Return the time corresponding to the next WEEKDAY calculated from TIME. WEEKDAY is an integer with 0 corresponding to Monday, 6 to Sunday. KEEP-TOFD-P, if non-NIL, indicates that the time portion of TIME should be carried over to the generated time. By default, 0:00h is returned for the time potions. Returns a timezone agnostic universal time.

ASCII-DIGIT-P (CH)

If the character is an ASCII digit, return the value of the digit.

ASCII-LETTER-P (CH)

Return true if the character is an ASCII alphabetic character.

COMPUTE-DATE-CHANGE (TIME1-ZUL TIME2-ZUL)

If TIME1-ZUL and TIME2-ZUL are on the same date, return nil, otherwise return the days between the two. See LOCAL-DATE-OFFSET for an explanation of the value returned.

CURRENT-TIME-UTC

Return the 'current' UTC time (as an integer-time). The 'current' time may have been cached by 'with-current-time-cached', or it may be skewed by 'with-current-time-function'.

CURRENT-TIME-ZONED

Return the 'current' UTC time (as a zoned time). The 'current' time may have been cached by 'with-current-time-cached', or it may be skewed by 'with-current-time-function'.

DATE-CHANGE-INDICATOR (TIME1-ZUL TIME2-ZUL)

Return a ``date change'' indicator that describes how many days are between TIME1-ZUL and TIME2-ZUL. If they are on the same date, " " is returned, otherwise it will be a string consisting of a #+ or a #- if TIME1-ZUL is before or after TIME2-ZUL and the number of days between the two.

DAY-OF-YEAR (TIME)

Extract the 1-based day-of-year from an integer-time. E.g. January 1 (of any year) --> 1 'time' is an integer-time. Result is an integer in the range [1,366].

DAYS-PER-MONTH (MONTH YEAR)

Return the number of days in a given month in a given year. 'month' is in the range [1,12] (where 1 == January). 'year' is the year -- which only affects the result for February.

DECODE-INTEGER-DATE (DATE)

Decode an integer-time into only its broken-down date components. Input is an integer-time. Result is the values <day> <month> <year> <dofw>. This function is equivalent to (decode-universal-time ... 0), but is precomputed and thus faster for years in the range [$it-cache-first-year,$it-cache-last-year].

DECODE-INTEGER-TIME (TIME)

Decode an integer-time into its broken-down components. Input is an integer-time. Result is the values <seconds> <minutes> <hours> <day> <month> <year> <dofw>. This function is equivalent to (decode-universal-time ... 0), but is precomputed and thus faster for years in the range [$it-cache-first-year,$it-cache-last-year].

DECODE-INTEGER-TOFD (TOFD)

Decode an integer-time into only its broken-down time-of-day components. Input is an integer-time. Result is the values <seconds> <minutes> <hours>. This function is equivalent to (decode-universal-time ... 0), but is precomputed and thus faster for years in the range [$it-cache-first-year,$it-cache-last-year].

DECODE-UNIVERSAL-TIME (UNIVERSAL-TIME &OPTIONAL TIME-ZONE)

Extend to decode negative numbers

DOFW-NAME (DOFW &KEY (SIZE SHORT) (CASE UPPER))

Return a string containing the English name of a numeric day-of-week. 'dofw' belongs to the range [0,6] (0==Monday). 'size' is one of :short (default) or :long, specifying size of name. 'case' is one of :upper (default), :mixed or :lower. Return value is a string, or NIL if the dofw is not in [0,6].

ENCODE-INTEGER-DATE (DAY MONTH YEAR)

Encode a broken-down date specification into integer-time. Input is the day, month, and year. Result is an integer-time (seconds since lisp epoch). This function is equivalent to (encode-integer-time 0 0 0 ...), but can be 3x as fast.

ENCODE-INTEGER-TIME (SECONDS MINUTES HOURS DAY MONTH YEAR)

Encode a broken-down time specification into integer-time. Input is the seconds, minutes, hours, day, month, and year. Result is an integer-time (seconds since lisp epoch). This function is equivalent to (encode-univeral-time ... 0), but is precomputed and thus faster for years in the range [$it-cache-first-year,$it-cache-last-year].

ENCODE-INTEGER-TOFD (SECONDS MINUTES HOURS)

Encode a broken-down time-of-day specification into integer-time. Input is the seconds, minutes, and hours. Result is an integer-tofd (seconds since midnight). This function is equivalent to (encode-integer-time ... 0 0 0), but is 7.5x as fast and does almost no consing (since a tofd always fits in a fixnum.

ENCODE-UNIVERSAL-TIME (SECOND MINUTE HOUR DATE MONTH YEAR &OPTIONAL TIME-ZONE)

Extend to return negative values for years < 1900

EXPLODE-ISO8601 (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date+tofd string into its numerical components. 'string' may have one of these syntaxes: YYYY-MM-DDThh:mm[:ss[.ffff...]]Z YYYY-MM-DDThh:mm[:ss[.ffff...]]Saa[:bb] YYYY-MM-DDThh:mm[:ss[.ffff...]] where: YYYY = year MM = month DD = day/date T = literal 'T' hh = hour mm = minute ss = second fff.. = fractional seconds Z = literal 'Z', meaning a UTC time S = timezone offset sign: either '-' or '+' aa = timezone offset hour bb = timezone offset minute The return values are the components: <seconds> [optional] <minutes> <hours> [required] <day> <month> <year> [required] <tz-offset minutes> <tz-offset hours> <tz-offset sign> [optional] <seconds fraction> [optional] All values are integers, except for <seconds fraction> (a rational), or missing optional values (NIL). <tz-offset sign> is zero iff the timestring is in the UTC 'Z' form; if any timezone is specified (even 00:00), it will be +1 or -1. <tz-offset minutes/hours> are zero if <tz-offset sign> is zero. All tz-offset values are NIL if timezone fields are not supplied. If parsing fails, all NILs are returned.

EXPLODE-ISO8601-DATE (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date string into its numerical components. 'string' may have one of precisely must be YYYY-MM-DD syntax. Return values are: <day> <month> <year> If parsing fails, all NILs are returned.

EXPLODE-ISO8601-TOFD (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 tofd string into its numerical components. 'string' may have one of these syntaxes: hh:mm[:ss[.ffff...]]Z hh:mm[:ss[.ffff...]]Saa[:bb] hh:mm[:ss[.ffff...]] where: hh = hour mm = minute ss = second fff.. = fractional seconds Z = literal 'Z', meaning a UTC time S = timezone offset sign: either '-' or '+' aa = timezone offset hour bb = timezone offset minute The return values are the components: <seconds> [optional] <minutes> <hours> [required] <tz-offset minutes> <tz-offset hours> <tz-offset sign> [optional] <seconds fraction> [optional] All values are integers, except for <seconds fraction> (a rational), or missing optional values (NIL). <tz-offset sign> is zero iff the timestring is in the UTC 'Z' form; if any timezone is specified (even 00:00), it will be +1 or -1. <tz-offset minutes/hours> are zero if <tz-offset sign> is zero. All tz-offset values are NIL if timezone fields are not supplied. If parsing fails, all NILs are returned.

EXPLODE-LOCAL-TIME (STRING &KEY (START 0) (END (LENGTH STRING)) DEFAULT-YEAR)

Explode a string into (local) date and tofd components. Valid input formats are (maybe?): [D]D-MTH[-YY[YY]] [D]D-MM-YYYY [D]D[-]M[M][-]YYYY YYYY-MM-D[D] YYYY[-]M[M][-]D[D] DDMMYY MM-YY - day is set to last day of month MM-YYYY - day is set to last day of month Return values are: <seconds> <minutes> <hours> <day> <month> <year>. 'year' may be NIL if no year was supplied.

EXPLODE-LOCAL-TOFD (STRING &KEY (START 0) (END (LENGTH STRING)))

Parse a string (or substring) as a local time-of-day. Valid formats are: HHMM HHMMSS H..H:MM H..H:MM:SS Returns multiple-values: <seconds> <minutes> <hours>

FIRST-MINUTE-OF-LOCAL-DATE (TIME)

Return the integer-time representing the first minute on the given date.

ILOGBIT-SET (INTEGER INDEX)

Given a fixnum and an index, return the fixnum with the index'ed bit set to one.

ILOGBIT-UNSET (INTEGER INDEX)

Given a fixnum and an index, return the fixnum with the index'ed bit set to zero.

ILOGSUBSETP (N1 N2)

Given two fixnums, return true if the bits set in n1 are a subset of the bits set in n2.

INTEGER-NUMBER-OF-DIGITS (I)

Return the number of digits in the printed representation of I, which must be a non-negative integer.

LAST-MINUTE-OF-LOCAL-DATE (TIME)

Return the integer-time representing the last minute on the given date.

LOCAL-DATE-EQUAL (DATE1 DATE2)

Return T if 'date1' and 'date2' have equal day, month, and year. 'date1' and 'date2' are integer-time's.

LOCAL-DATE-LONG-DOFW-NAME (TIME &KEY (CASE UPPER))

Return a string with the full English name of the day-of-week.

LOCAL-DATE-OFFSET (TIME1 TIME2)

Return the (integer) difference in _date_ between two local times. This is essentially the difference in 'printed days', not the difference in '24-hour periods'. For example, '2005-03-05 23:00' and '2005-03-06 01:00' will yield a 1 day difference in date, even though they are only 2 hours apart. 'time1' and 'time2' are local 'integer-times'. The result is positive if time2 is later than time1.

LOCAL-DATE-ONLY (TIME)

Zero the time bits of a integer-time, leaving the date bits alone.

LOCAL-DATE-TO-ISO8601-STRING (DATE)

Return the given local integer-date DATE as a string formatted as YYYY-MM-DDD.

LOCAL-DATE-TO-STRING (DATE &OPTIONAL FORMAT)

Return the given local integer-date DATE as string. FORMAT specifies how the date should be formatted. The following keywords are accepted for FORMAT: :DATE-ONLY -> DDMTHYYY :BRIEF -> DD-MTH-YYYY HH:MM any of (:DDMTH :DDMTHYY :DDMTHYYYY :DD-MTH-YYYY :DDMMYY :MMDDYY :DDMMYYYY :MMDDYYYY :YYYYMMDD :YYYYMM :YYMMDD :YYYY-MM-DD) -> whatever WRITE-LOCAL-DATE produces for that format specification. For all other values of FORMAT, YYYY-MM-DD HH:MM:SS is produced.

LOCAL-DATE-TO-STRING-FORMAT (DATE FORMAT)

Return the given local integer-date DATE as formatted string according to the FORMAT, SHOW-WEEKDAY and USE-UPPERCASE arguments as expected by WRITE-EXPLODED-DATE.

LOCAL-DATE-TO-UTC (LOCAL-DATE LOCAL-TOFD TZOFFSET)

Convert the given LOCAL-DATE/LOCAL-TOFD to UTC and return the date part. For example: 1-MAR 23:00 EST -> 2-MAR

LOCAL-TIME-TO-UTC (TIME-LOCAL TZOFFSET)

Given a local integer-time and a TZ offset, return the UTC integer-time.

LOCAL-TOFD-ONLY (TIME)

Zero the date bits of a integer-time, leaving the tofd bits alone.

LOCAL-TOFD-TO-STRING (TOFD &OPTIONAL (FORMAT HH-MM))

Return the given time of day TOFD as string. FORMAT may be specified to control the format produced by WRITE-LOCAL-TOFD, it defaults to :HH-MM.

LOWER-CASE-ASCII-LETTER-P (CH)

Return true if the character is an ASCII lowercase character.

MERGE-DATE-AND-TOFD (DATE TOFD)

Merge a 'date' with a 'tofd'. Take the date components of 'date' (an integer-time) and merge them with the time components of 'tofd' (another integer-time), generating a new integer-time. ('date' and 'time' should be local to the same TZ, although the result is effectively in the same relative TZ as 'tofd'.)

MERGE-DATE-AND-TOFD-ZONED (DATE ZUL &OPTIONAL (LOCAL-DATE-OFFSET 0))

Combines an integer-date and a the time portion of a zoned-time, and optionally a day offset for the local-date.

MONTH-NAME (MONTH &KEY (SIZE SHORT) (CASE UPPER))

Return a string containing the English name of a numeric month. 'month' belongs to the range [1,12] (1==January). 'size' is one of :short (default) or :long, specifying size of name. 'case' is one of :upper (default), :mixed or :lower. Return value is a string, or NIL if the month is not in [1,12].

OVERRIDE-LOCAL-TIME (TIME &KEY SECONDS MINUTES HOURS DAY MONTH YEAR)

Override specific date/tofd components of an integer-time. Returns the new integer-time constructed by replacing the specified components of the original integer-time 'time'.

PAD-STRING-TO-WIDTH (STR WIDTH PAD-CHAR)

Pad the string on the left until it is as long as width. If it is already longer than that, signal an exception.

PARSE-DURATION (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert the duration 'string' to a number of seconds. 'string' may take one of the following forms: HH:MM HH:MM:SS HHMM HHMMSS +HH:MM +HH:MM:SS +HHMM +HHMMSS -HH:MM -HH:MM:SS -HHMM -HHMMSS The sign of the result reflects the sign of the duration.

PARSE-ISO8601-DATE (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date (sub)string into an integer-date. Must be in YYYY-MM-DD syntax. If parsing fails, NIL is returned.

PARSE-ISO8601-LOCAL (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date+tofd (sub)string into an integer-time. (For allowed syntaxes, see 'explode-iso8601'.) Any fractional seconds are truncated. Any time zone specification is ignored. If parsing fails, NIL is returned.

PARSE-ISO8601-TOFD-ZONED (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 tofd (sub)string into a zoned-time. (For allowed syntaxes, see 'explode-iso8601-tofd'.) Any fractional seconds are truncated. If parsing fails, NIL is returned.

PARSE-ISO8601-UTC (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date+tofd (sub)string into a UTC integer-time. (For allowed syntaxes, see 'explode-iso8601'.) Any fractional seconds are truncated. If parsing fails, NIL is returned.

PARSE-ISO8601-ZONED (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert an ISO-8601 date+tofd (sub)string into a zoned-time. (The allowed syntax is YYYY-MM-DDThh:mm[:ss[.ffff...]]Saa:bb; see 'explode-iso8601' for an explanation.) Any fractional seconds are truncated. If parsing fails, NIL is returned.

PARSE-LOCAL-DATE (STRING &KEY (START 0) (END (LENGTH STRING)) (GUESS-YEAR UTC-FUTURE) (GUESS-YEAR-OFFSET 0) (GUESS-CENTURY UNIX-Y2K))

Parse a (sub)string as a local date, neglecting tofd components. STRING is the time string to parse. START and END are optional bounds. GUESS-YEAR specifies how the year should be inferred if it is missing from STRING. The options for GUESS-YEAR are: a number - The given number is used when STRING does not specify a year. :utc-future - Choose the year such that the time is in the future, relative to the current printed UTC time. [default] :utc-current - Use the year from the current printed UTC time. NIL - Return NIL if no year is specified. :utc-past - Choose the year such that the time is in the past, relative to the current printed UTC time. GUESS-YEAR-OFFSET specifies an offset (in seconds) which is added to the current UTC time before inferring the year for a yearless STRING. It is applicable only when GUESS-YEAR is :UTC-FUTURE or :UTC-PAST. GUESS-YEAR-OFFSET defaults to zero. GUESS-CENTURY specifies how the year should be interpreted if it is specified as (exactly) two digits. The options are: :utc-nearest - Choose a date within 50 years of the current UTC date. :utc-past - Choose the latest century giving a past UTC date. :utc-future - Choose the earliest century not giving a past UTC date. :unix-y2k - Calls %year-from-2digit-year, resulting in a year in the range 1970 to 2069 [default]. The function returns a local date represented as an integer-time, or NIL.

PARSE-LOCAL-TIME (STRING &KEY (START 0) (END (LENGTH STRING)) (GUESS-YEAR UTC-FUTURE) (GUESS-YEAR-OFFSET 0) (GUESS-CENTURY UNIX-Y2K))

Parse a (sub)string as a local time (date+tofd). STRING is the time string to parse. START and END are optional bounds. GUESS-YEAR specifies how the year should be inferred if it is missing from STRING. The options for GUESS-YEAR are: A number - The given number is used when STRING does not specify a year. :utc-future - Choose the year such that the time is in the future (or same date), relative to the current printed UTC date. [default] :utc-current - Use the year from the current printed UTC date. NIL - Return NIL if no year is specified. :utc-past - Choose the year such that the time is in the past (or same date), relative to the current printed UTC date. GUESS-YEAR-OFFSET specifies an offset (in seconds) which is added to the current UTC time before inferring the year for a yearless STRING. It is applicable only when GUESS-YEAR is :UTC-FUTURE or :UTC-PAST. GUESS-YEAR-OFFSET defaults to zero. GUESS-CENTURY specifies how the year should be interpreted if it is specified as (exactly) two digits. The options are: :utc-nearest - Choose a date within 50 years of the current UTC date. :utc-past - Choose the latest century giving a past UTC date. :utc-future - Choose the earliest century not giving a past UTC date. :unix-y2k - Calls %year-from-2digit-year, resulting in a year in the range 1970 to 2069 [default]. The function returns a local datetime as an integer-time, or NIL.

PARSE-LOCAL-TOFD (STRING &KEY (START 0) (END (LENGTH STRING)))

Parse a string (or substring) as a local tofd. Valid formats are: HHMM HHMMSS HH:MM HH:MM:SS Returns the number of seconds since (local) midnight.

ROLL-TIME (TIME &KEY (SECONDS 0) (MINUTES 0) (HOURS 0) (DAYS 0) (MONTHS 0) (YEARS 0))

Return an integer-time before/after TIME by SECONDS, MINUTES, HOURS, DAYS, MONTHS or YEARS. TIME - an integer-time (number of seconds since epoch). SECONDS, MINUTES, HOURS, DAYS, MONTHS, YEARS - integers. ROLL-TIME operates by adding/subtracting SECONDS, MINUTES, HOURS, DAYS, MONTHS and YEARS (in that order) to the facsimile time TIME. ROLL-TIME treats TIME simply as the number of seconds since epoch ignoring DST, time zones and anything else which isn't passed as an argument to `encode-integer-time'. Notes: 1) The length of months, expressed as a number of days, varies. Therefore it does not always hold that: (= x (roll-time (roll-time x :months M :years Y) :months -M :years -Y)) 2) If the result of rolling, even in an interedmiate step, ends up before 1900-01-01T00:00:00 we lose. Example: (roll-time (encode-universal-time 0 0 0 1 1 1900) :days -31 :months 3) ==> ERROR

ROUND-TIME-TO-NEXT-MINUTE (TIME)

Round up an integer-time to the nearest larger minute. Returns an integer number of minutes, which, when multiplied by $1minute, will be 0-60 greater than the input.

SERVER-SYSTEM-TIME-UTC

Return the server's true UTC system time (as an integer-time). This function returns the real UTC time as seen by the server's clock, and should only be used in situations such as logging, where the true physical clock time is important. Otherwise, one should always use CURRENT-TIME-UTC.

TIME-SPEEDER-UPPER (RATE)

Returns a lambda that generates time at 'rate' x normal rate. For use in the (with-current-time-function) macro. Note that this clock still 'ticks' once per wallclock second; it is just that each tick moves the time forward a large amount. If 'current-time-utc' is called multiple times within that second, time will appear to be frozen. See 'time-speeder-upper-hires' for a clock that ticks more often.

TIME-SPEEDER-UPPER-HIRES (RATE)

Returns a lambda that generates time at 'rate' x normal rate, at high resolution. For use in the (with-current-time-function) macro. This clock ticks at the rate given by 'internal-time-units-per-second', typically 100. Note: this clock breaks nesting, since it only relies on the outer scope to set the initial time for the clock.

TIME-TO-ISO8601-STRING (TIME UTC/LOCAL TIME-FORMAT)

Create a string in ISO-8601 format from an integer-time.

UPPER-CASE-ASCII-LETTER-P (CH)

Return true if the character is an ASCII uppercase character.

UTC-DATE-TO-LOCAL (UTC-DATE LOCAL-TOFD TZOFFSET)

Return the local date for the given local time and UTC date. For example: 2-MAR 23:00 EST -> 1-MAR

UTC-IS-AFTER-UTC-P (A B)

Return T if 'a' succeeds 'b' in absolute (UTC) time.

UTC-IS-BEFORE-UTC-P (A B)

Return T if 'a' precedes 'b' in absolute (UTC) time.

UTC-TIME-TO-LOCAL (TIME-UTC TZOFFSET)

Given a UTC integer-time and a TZ offset, return the local integer-time.

UTC-TO-ISO8601-STRING (TIME-UTC)

Create a string in ISO-8601 format from a UTC integer-time.

WRITE-EXPLODED-DATE (DAY MONTH YEAR WEEKDAY &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (FORMAT YYYY-MM-DD) (SHOW-WEEKDAY NIL) (USE-UPPERCASE T))

Write an exploded local date to a stream; input is the component fixnums day, month, year, weekday. If 'weekday' is not NIL, ':show-weekday' specifies where to write an English weekday: :before, :before-dash - before the date :after, :dash-after - after the date NIL - do not display weekday If 'use-uppercase' is NIL, mixed-case is used for English months and weekdays. Possible output formats are: English Month: :ddmth '07JAN' :ddmthyy '07JAN99' :ddmthyyyy '07JAN1999' :dd-mth-yyyy '07-JAN-1999' Numeric Month: :ddmmyy '070199' :mmddyy '010799' :ddmmyyyy '07011999' :yyyymmdd '19990107' :yymmdd '990107' :yyyy-mm-dd '1999-01-07' :nu/mm/yy '01/99' :nu/mm/yyyy '01/1999' :nu/mmyy '0199' Return value is NIL.

WRITE-EXPLODED-TOFD (SECONDS MINUTES HOURS &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (FORMAT HH-MM))

Write an exploded local tofd to a stream; input is the component seconds, minutes, and hours. Possible output formats are: :hh-mm = HH:MM :hh-mm-ss = HH:MM:SS :hh-mm-ap = HH:MMAM, HH:MMPM :_h-mm = H:MM :_h-mm-ap = H:MMa, H:MMp :hhmm = HHMM :hhmmss = HHMMSS :hhmmap = HHMMA, HHMMP :_hmmap = HMMA, HMMP The "_h" formats use a leading space instead of a leading zero. Return value is NIL.

WRITE-INTEGER (INTEGER STREAM &KEY WIDTH (PADDING ))

Write the integer to the stream. If it's a fixnum and width is provided, pad it to that width with the padding character.

WRITE-INTEGER-TO-STRING (INTEGER &KEY WIDTH (PADDING ))

Convenience function for int to string conversion. Is actually a lot cheaper than prin1-to-string (1/3 the time and consing)

WRITE-ISO8601-LOCAL (TIME &OPTIONAL (STREAM *STANDARD-OUTPUT*))

Write an integer-time to a stream in ISO-8601 format. decode as UTC, write as local (w/o ZULU indicator).

WRITE-ISO8601-UTC (TIME-UTC &OPTIONAL (STREAM *STANDARD-OUTPUT*))

Write an integer-time to a stream in ISO-8601 format. decode as UTC, write with UTC/ZULU indicator.

WRITE-LOCAL-DATE (DATE &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (FORMAT YYYY-MM-DD) (SHOW-WEEKDAY NIL) (USE-UPPERCASE T))

Write the given local integer-date DATE to STREAM according to the FORMAT, SHOW-WEEKDAY and USE-UPPERCASE arguments as expected by WRITE-EXPLODED-DATE.

WRITE-LOCAL-TOFD (TOFD &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (FORMAT HH-MM))

Write a local tofd to a stream. 'tofd' is an integer-tofd, i.e. seconds from midnight. Possible output formats are: :hh-mm = HH:MM :hh-mm-ss = HH:MM:SS :hh-mm-ap = HH:MMAM, HH:MMPM :hhmm = HHMM :hhmmss = HHMMSS :hhmmap = HHMMA, HHMMP Return value is NIL.

WRITE-PADDED-FIXNUM (FIXNUM STREAM WIDTH PAD-CHAR)

Write the fixnum to the stream, with the given width and padding.

WRITE-UNPADDED-FIXNUM (FIXNUM STREAM)

Write the fixnum to the stream. This is more efficient than using the regular Lisp printer.

WRITE-ZONED-TIME (ZUL &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (DATE-AS YYYY-MM-DD) (TIME-AS HH-MM TIME-AS-SUPPLIED-P) (SHOW-WEEKDAY NIL) (AS-UTC NIL) (SHOW-TIMEZONE T SHOW-TZ-SUPPLIED-P) (USE-UPPERCASE T))

Write the zoned-time ZUL to the STREAM. If DATE-AS is specified as :ISO8601, use ISO-8601 format with possible variations as specified by DATE-AS and TIME-AS. AS-UTC, if non-NIL, indicates that the the time should be considered as being UTC, with no timezone information output. The DATE-AS and TIME-AS arguments accept format arguments as accepted by WRITE-EXPLODED-DATE and WRITE-EXPLODED-TOFD.

Undocumented

%DEFCONSTANT-EQX-VALUE (SYMBOL EXPR EQX)

%SHOW-ALL-NEW-TIME-FORMATS (TIME)

ADVANCE-LOCAL-TIME (TIME &KEY (SECONDS 0) (MINUTES 0) (HOURS 0) (DAYS 0))

CURRENT-TIME-UTC-DB-OVERRIDE

GET-LOCAL-TIME (TIME)

ITUS-TO-MS (ITUS)

ITUS-TO-US (ITUS)

MAKE-ZONED-TIME (&KEY UTC LOCAL TZOFFSET)

PARSE-RIGHT-TRIMMING-WHITESPACE (PARSER TYPE STRING &REST KEYS &KEY END &ALLOW-OTHER-KEYS)

STRING-TO-INTEGER (OBJECT &REST KEYS)

WRITE-DURATION (DURATION &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (FORMAT HH-MM) (SHOW-PLUS NIL))

WRITE-ISO8601-TIME (TIME UTC/LOCAL TIME-FORMAT &OPTIONAL (STREAM *STANDARD-OUTPUT*))

WRITE-LOCAL-DATE-RANGE (TIME1 TIME2 &OPTIONAL (STREAM *STANDARD-OUTPUT*) &KEY (CASE UPPER) LONG-P (SHOW-WEEKDAY AUTOMATIC) SHOW-YEAR-P)

WRITE-PADDED-FIXNUM-INTERNAL (FIXNUM ABSOLUTE-VALUE WIDTH STREAM PAD-CHAR)

MACRO

Private

CHECK-TYPES (&REST CLAUSES)

Each clause looks like (type form1 form2 ..). For each clause, assert that all the forms are of that type. Example: (check-types (integer x y) (string z) ...).

I* (&REST FIXNUMS)

A version of the * function that can only be used on fixnums.

I+ (&REST FIXNUMS)

A version of the + function that can only be used on fixnums.

I- (NUMBER &REST FIXNUMS)

A version of the - function that can only be used on fixnums.

I/ (X Y)

A version of the / function that can only be used on fixnums.

I/= (&REST FIXNUMS)

A version of the /= function that can only be used on fixnums.

I1+ (X)

A version of the 1+ function that can only be used on fixnums.

I1- (X)

A version of the 1- function that can only be used on fixnums.

I< (&REST FIXNUMS)

A version of the < function that can only be used on fixnums.

I<= (&REST FIXNUMS)

A version of the <= function that can only be used on fixnums.

I= (&REST FIXNUMS)

A version of the = function that can only be used on fixnums.

I> (&REST FIXNUMS)

A version of the > function that can only be used on fixnums.

I>= (&REST FIXNUMS)

A version of the >= function that can only be used on fixnums.

IASH (VALUE COUNT)

A version of the ash function that can only be used on fixnums.

ICEILING (X Y)

A version of the ceiling function that can only be used on fixnums.

ICEILING+ (X Y)

A version of the ceiling+ function that can only be used on fixnums.

IDECF (PLACE &OPTIONAL (DELTA 1) &ENVIRONMENT ENV)

Set place to - of place and argument, for fixnums only.

IDPB (NEWVALUE BYTESPEC VALUE)

A version of the dpb function that can only be used on fixnums.

IFLOOR (X Y)

A version of the floor function that can only be used on fixnums.

IFLOOR+ (X Y)

A version of the floor+ function that can only be used on fixnums.

IINCF (PLACE &OPTIONAL (DELTA 1) &ENVIRONMENT ENV)

Set place to + of place and argument, for fixnums only.

ILDB (BYTESPEC VALUE)

A version of the ldb function that can only be used on fixnums.

ILOGAND (&REST FIXNUMS)

A version of the logand function that can only be used on fixnums.

ILOGANDC2 (X Y)

A version of the logandc2 function that can only be used on fixnums.

ILOGBITP (INDEX INTEGER)

A version of the logbitp function that can only be used on fixnums.

ILOGCOUNT (NUMBER)

A version of the logcount function that can only be used on fixnums.

ILOGEQV (&REST FIXNUMS)

A version of the logeqv function that can only be used on fixnums.

ILOGIOR (&REST FIXNUMS)

A version of the logior function that can only be used on fixnums.

ILOGNOT (X)

A version of the lognot function that can only be used on fixnums.

ILOGTEST (X Y)

A version of the logtest function that can only be used on fixnums.

ILOGXOR (&REST FIXNUMS)

A version of the logxor function that can only be used on fixnums.

IMAX (NUMBER &REST FIXNUMS)

A version of the max function that can only be used on fixnums.

IMAXF (PLACE X &REST XS &ENVIRONMENT ENV)

Set place to max of place and argument, for fixnums only.

IMIN (NUMBER &REST FIXNUMS)

A version of the min function that can only be used on fixnums.

IMINF (PLACE X &REST XS &ENVIRONMENT ENV)

Set place to min of place and argument, for fixnums only.

IMINUSP (X)

A version of the minusp function that can only be used on fixnums.

IMOD (X Y)

A version of the mod function that can only be used on fixnums.

IPLUSP (X)

A version of the plusp function that can only be used on fixnums.

IREM (X Y)

A version of the rem function that can only be used on fixnums.

ITRUNCATE (X Y)

A version of the truncate function that can only be used on fixnums.

IZEROP (X)

A version of the zerop function that can only be used on fixnums.

MAXF (PLACE X &REST XS &ENVIRONMENT ENV)

Set place to max of place and argument.

MINF (PLACE X &REST XS &ENVIRONMENT ENV)

Set place to min of place and argument.

MULTIPLE-VALUE-LET (DECLS &BODY BODY)

MULTIPLE-VALUE-LET ({(Varlist [Multiple-Value]) | (Var [Value]) | Var}*) Declaration* Form* During evaluation of the Forms, Bind the Vars to the result of evaluating the Value forms. If a list of variables is given, they are bound to each of the VALUES returned by the expression, in order. The variables are bound in parallel after all of the Values are evaluated.

MULTIPLE-VALUE-LET* ((DECL &REST DECLS) &BODY BODY)

MULTIPLE-VALUE-LET* ({(Varlist [Multiple-Value]) | (Var [Value]) | Var}*) Declaration* Form* During evaluation of the Forms, Bind the Vars to the result of evaluating the Value forms. If a list of variables is given, they are bound to each of the VALUES returned by the expression, in order. The variables are bound in series, so any declaration may refer to any earlier one.

WITH-CURRENT-TIME-CACHED ((&OPTIONAL OVERRIDE-TIME-UTC) &BODY BODY)

Create a scope which caches/freezes the current UTC time. This scope caches the result of (current-time-utc). Evaluations of (current-time-utc) within the scope will return the cached value. If the optional 'override-time-utc' is provided, then the scope will cache that value instead.

WITH-CURRENT-TIME-FUNCTION ((NEW-TIME-FUNCTION &KEY ALLOW-NESTING?) &BODY BODY)

Create a scope in which the current time is generated by a function. Within this scope, evaluations of (current-time-utc) will report the time as generated by 'new-time-function', instead of the time as reported by the operating system. For example, to create a scope where time runs 5x faster than normal: (with-current-time-function ((time-speeder-upper 5)) (process-sleep 1) (current-time-utc)) ; This returns a time 4s in the future These scopes may be nested. Nesting is disabled by default, since you're probably shooting yourself in the foot by it. The inner-most function is first executed; if it refers to (current-time-utc), which (time-speeder-upper) does, then the function in the outer scope will provide that value. E.g. nesting two (tims-speeder-upper)s will have the effect of speeding time by the product of their rates.

WITH-GENSYMS ((&REST BINDINGS) &BODY BODY)

BINDINGS is a list of clauses. The canonical clause looks like (VARIABLE PREFIX) where VARIABLE is a Lisp variable, and PREFIX is a string (or anything acceptable to the STRING) function. Each VARIABLE is bound to a gensym, made with the PREFIX, and the body is run inside those bindings. A clause of the form (VARIABLE) or VARIABLE is treated as (VARIABLE VARIABLE). This is available at compile-time, so macro bodies can use it.

WITHOUT-CURRENT-TIME-CACHED (&BODY BODY)

DEPRECATED; use 'without-current-time-trickery' instead.

WITHOUT-CURRENT-TIME-TRICKERY (&BODY BODY)

Create a scope that undoes any of the current-time caches/functions.

Undocumented

DEFCONSTANT-EQL (SYMBOL EXPR &OPTIONAL DOC)

DEFCONSTANT-EQUAL (SYMBOL EXPR &OPTIONAL DOC)

DEFCONSTANT-EQUALP (SYMBOL EXPR &OPTIONAL DOC)

DEFCONSTANT-EQX (SYMBOL EXPR EQX &OPTIONAL DOC)

DEFCONSTANT-UNEQUAL (SYMBOL EXPR &OPTIONAL DOC)

DEFUN-INLINE (NAME ARGLIST &BODY BODY)

WITH-CURRENT-INTEGER-TIME-FIXED ((INTEGER-TIME) &BODY BODY)

WITH-CURRENT-TIME-FIXED ((SECOND MINUTE HOUR DAY MONTH YEAR) &BODY BODY)

WITH-VIRTUAL-SLEEP ((&KEY (DAYS 0) (HOURS 0) (MINS 0) (SECS 0)) &BODY BODY)

GENERIC-FUNCTION

Private

ZONED-TIME (TIME-DESIGNATOR)

Transform the argument into a ZONED-TIME instance. A string is parse in ISO8601 syntax, a ZONED-TIME instance is returned, and an integer is used as the utc argument to construct a new ZONED-TIME instance with offset 0.

Undocumented

ADD-DAYS (Z DAYS)

DURATION (A B)

ENDS-WITH (STRING SUFFIX &KEY (END (LENGTH STRING)))

LOCAL-TIME (ZUL)

MAKE-ZONED-DATE (Z)

ZONED-TIME-EQUAL-P (A B)

SLOT-ACCESSOR

Private

TZOFFSET (OBJECT)

Offset (seconds) to local timezone (from UTC)

UTC-TIME (OBJECT)

UTC integer-time representation of moment

VARIABLE

Private

$DAY-FROM-DAYS

An array which maps (days since epoch) --> (day-of-month) where day-of-month is in the range [1,N]. The zeroth entry in the array is for $it-cache-first-day, the last entry is for $it-cache-last-day.

$DAYS-UNTIL-MONTH

An array mapping (month) --> (days before beginning of month) The value for months after February is, of course, incorrect during leap years.

$DOFW-FROM-DAYS

An array which maps (days since epoch) --> (day-of-week) where day-of-week is in the range [0,6] for [mon,sun]. The zeroth entry in the array is for $it-cache-first-day, the last entry is for $it-cache-last-day.

$MONTH-FROM-DAYS

An array which maps (days since epoch) --> (month-of-year), where month-of-year is in the range [1,12]. The zeroth entry in the array is for $it-cache-first-day, the last entry is for $it-cache-last-day.

$YEAR-FROM-DAYS

An array which maps (days since epoch) --> (year) The zeroth entry in the array is for $it-cache-first-day, the last entry is for $it-cache-last-day.

*UNPADDED-INTEGER-STRINGS*

A 1000-element vector of the printed representation of each integer without any padding.

*ZERO-PADDED-INTEGER-STRINGS-2*

A 100-element vector of the printed representation of each integer zero-padded to two characters.

*ZERO-PADDED-INTEGER-STRINGS-4*

A 10000-element vector of the printed representation of each integer zero-padded to two characters.

Undocumented

*CURRENT-TIME-FUNCTION*

CLASS

Private

ZONED-TIME (TIME-DESIGNATOR)

An immutable time object which includes timezone information. If both local and UTC views are ever relevant for some absolute temporal quantity, then a zoned-time should be used to represent that quantity.

CONSTANT

Private

$12HOURS

The duration of one half-day, in integer-time.

$1HOUR

The duration of one hour, in integer-time.

$1MINUTE

The duration of one minute, in integer-time.

$1SECOND

The duration of one second, in integer-time.

$1WEEK

The duration of one week, in integer-time.

$24HOURS

The duration of one day, in integer-time.

$4HOURS

The duration of four hours, in integer-time.

$DAYS-PER-FEBRUARY-YEAR

An array which maps (year) --> (days in february that year) The map starts with the first month of year '$it-cache-first-year' and ends with the last month of year '$it-cache-last-year'.

$DAYS-PER-MONTH

An array mapping (month) --> (days in month) The value for February is, of course, incorrect during leap years, hence the need for %days-per-february-year defined above.

$DAYS-UNTIL-YEAR-MONTH

An array which maps (year,month) --> (days preceding that year/month) where 'days' starts at the lisp epoch. The map starts with the first month of year '$it-cache-first-year' and ends with the last month of year '$it-cache-last-year'. And, there are 13 months in a year -- i.e. [0,12] are valid months, and month 0 is the same as month 1.

$FIRST-MINUTE-OF-DAY

The first minute of a day (i.e. 00:00, midnight), in integer-time.

$FIXNUM-MAX-BIT-INDEX

The maximum amount that a fixnum can be shifted.

$IT-CACHE-FIRST-DAY

The first day (since epoch) of precomputed integer-time en-/de-coding.

$IT-CACHE-FIRST-YEAR

The first year of precomputed integer-time en-/de-coding

$IT-CACHE-LAST-DAY

The last day (since epoch) of precomputed integer-time en-/de-coding.

$IT-CACHE-LAST-YEAR

The last year of precomputed integer-time en-/de-coding

$LARGEST-TZ-OFFSET

The largest possible timezone offset, in integer-time.

$LAST-MINUTE-OF-DAY

The last minute of a day (i.e. 23:59), in integer-time.

$TIME-IN-DISTANT-FUTURE

A time in the distant future.

$TIME-IN-DISTANT-PAST

A time in the distant past.

+400-YEARS-OF-SECONDS+

The number of seconds in four hundred years

Undocumented

$LOWERCASE-DAYS

$LOWERCASE-DAYS-LONG

$LOWERCASE-DAYS-WS

$LOWERCASE-MONTHS

$LOWERCASE-MONTHS-LONG

$MIXEDCASE-DAYS

$MIXEDCASE-DAYS-LONG

$MIXEDCASE-DAYS-WS

$MIXEDCASE-MONTHS

$MIXEDCASE-MONTHS-LONG

$UPPERCASE-DAYS

$UPPERCASE-DAYS-LONG

$UPPERCASE-DAYS-WS

$UPPERCASE-MONTHS

$UPPERCASE-MONTHS-LONG