Common Lisp Package: DATE-CALC

README:

FUNCTION

Public

ADD-DELTA-DAYS (YEAR MONTH DAY DELTA)

This function returns (values year month day) such that it is YEAR MONTH DAY plus DELTA days

ADD-DELTA-DHMS (YEAR MONTH DAY HOUR MIN SEC DD DH DM DS)

This function serves to add a days, hours, minutes and seconds offset to a given date and time (YEAR MONTH DAY HOUR MINUTE SECOND DDAY DHOUR DMINUTE DSECOND), in order to answer questions like "today and now plus 7 days but minus 5 hours and then plus 30 minutes, what date and time gives that?". Returns: (values y m d h min sec)

ADD-DELTA-YM (YEAR MONTH DAY DY DM)

This function adds DYEAR and DMONTH offset to YEAR MONTH DAY.

ADD-DELTA-YMD (YEAR MONTH DAY DY DM DD)

This function adds DYEAR DMONTH and DDAY offset to YEAR MONTH DAY.

ADD-DELTA-YMDHMS (YEAR MONTH DAY HOUR MIN SEC DYEAR DMONTH DDAY DH DM DS)

This function is the same as add-delta-ymd except that a time offset may be given in addition to the year, month and day offset

ADD-YEAR-MONTH (YEAR MONTH DY DM)

This function adds DYEAR and DMONTH offset to YEAR and MONTH.

BUSINESS-TO-STANDARD (YEAR WEEK DOW)

This function converts a given date from business notation YEAR WEEK DOW to standard notation year month day. DOW is not CL conform.

CENTER (STRING WIDTH)

Return a string that is WIDTH long with STRING centered in it.

CHECK-BUSINESS-P (YEAR WEEK DOW)

This function returns true if the given three numerical values YEAR WEEK DOW constitute a valid date in business format, and nil otherwise. Beware that this function does NOT compute whether a given date is a business day (i.e., Monday to Friday)! To do so, use (< (day-of-week year month day) 6) instead. DOW not CL conform.

CHECK-DATE (YEAR MONTH DAY)

This function returns t if the given three numerical values YEAR MONTH DAY constitute a valid date, and nil otherwise.

CHECK-TIME-P (HOUR MIN SEC)

This function returns t if the given three numerical values HOUR MIN SEC constitute a valid time, and nil otherwise.

CL-BUSINESS-TO-STANDARD (YEAR WEEK DOW)

This function converts a given date from business notation YEAR WEEK DOW to standard notation year month day. DOW is CL conform.

CL-CHECK-BUSINESS-P (YEAR WEEK DOW)

This function returns true if the given three numerical values YEAR WEEK DOW constitute a valid date in business format for CL (Monday=0), and nil otherwise. DOW is CL conform.

CL-DAY-OF-WEEK (YEAR MONTH DAY)

This function returns the DOW of YEAR MONTH DAY. DOW CL conform.

CL-DECODE-DAY-OF-WEEK (STR)

Returns number of weekday. STR can partially name the Weekday. DOW is CL conform.

CL-NTH-WEEKDAY-OF-MONTH-YEAR (YEAR MONTH DOW N)

This function returns the (year month day) of the N-th day of week DOW in the given MONTH and YEAR; such as, for example, the 3rd Thursday of a given month and year. DOW is CL conform.

CL-STANDARD-TO-BUSINESS (YEAR MONTH DAY)

This function converts a given date from standard notation YEAR MONTH DAY to business notation year week day of week. DOW is CL conform.

CL-SYSTEM-CLOCK (GMT TIME)

This function returns (values year month day hour min sec doy dow dst) based on current system clock. DOW is CL conform.

CL-WEEKS-IN-YEAR (YEAR)

This function returns the number of weeks in the given YEAR for CL DOW conform numbering (Monday=0)., i.e., either 52 or 53.

DATE-TO-DAYS (YEAR MONTH DAY)

This function returns the (absolute) number of the day of the given date, where counting starts at the 1.Jan 1.

DATE-TO-TEXT (YEAR MONTH DAY)

Return a pretty print string of YEAR MONTH DAY in DOW-TXT(SHORT) DAY MONTH YEAR with a little bit of sorting for language.

DATE-TO-TEXT-LONG (YEAR MONTH DAY)

Return a pretty print string of YEAR MONTH DAY in DOW-TXT(LONG) DAY MONTH YEAR with a little bit of sorting for language.

DAY-OF-WEEK (YEAR MONTH DAY)

This function returns the DOW of YEAR MONTH DAY. DOW not CL conform.

DAY-OF-YEAR (YEAR MONTH DAY)

This function returns the sum of the number of days in the months starting with January up to and including MONTH in the given year YEAR. 0 on failure.

DAYS-IN-MONTH (YEAR MONTH)

This function returns the number of days in the given MONTH of the given YEAR.

DAYS-IN-YEAR (YEAR &OPTIONAL MONTH)

This function returns the number of days in the given YEAR and optional MONTH. If MONTH is [1..12], return the number of days in that YEAR as of the last of that MONTH.

DECODE-DAY-OF-WEEK (STR)

Returns number of weekday. STR can partially name the Weekday. DOW is not CL conform.

DECODE-LANGUAGE (NUM)

Returns the Language of number NUM.

DECODE-MONTH (STR)

Returns number of month. STR can partially name the month. Computes a (search ...:test #'char-equal).

DELTA-DAYS (YEAR1 MONTH1 DAY1 YEAR2 MONTH2 DAY2)

This function returns the difference in days between Y1 M1 D1 and Y2 M2 D2.

DELTA-DHMS (YEAR1 MONTH1 DAY1 HOUR1 MIN1 SEC1 YEAR2 MONTH2 DAY2 HOUR2 MIN2 SEC2)

Returns the difference in (values d h m s) between the two given dates with times (Y1 M1 D1 H1 MIN1 SEC1 and Y2 M2 D2 H2 MIN2 SEC2).

DELTA-HMS (HOUR1 MIN1 SEC1 HOUR2 MIN2 SEC2)

This function returns the difference of H1 M1 S1 and H2 M2 S2 in (values d h m s).

DELTA-YMD (YEAR1 MONTH1 DAY1 YEAR2 MONTH2 DAY2)

This function returns the difference (values YEAR MONTH DAYS) between the two dates Y1M1D1 and Y2M2D2.

DELTA-YMDHMS (YEAR1 MONTH1 DAY1 HOUR1 MIN1 SEC1 YEAR2 MONTH2 DAY2 HOUR2 MIN2 SEC2)

This function returns the difference (values YEAR MONTH DAYS HOUR MINUTE SEC) between the two dates Y1 M1 D1 H1 MI1 S1 and Y2 M2 D2 H2 MI2 S2.

FIXED-WINDOW (YEAR)

Convert two digit YEAR to four digit YEAR; YEAR<=70 -> 2000+YEAR; YEAR<100&&>70 -> 1900+YEAR.

ISO-LC (CHAR)

Returns lower case CHAR.

ISO-UC (CHAR)

Returns upper case CHAR.

LEAP-YEAR (YEAR)

This function returns 1 if the given YEAR is a leap year and 0 otherwise.

LEAP-YEAR-P (YEAR)

This function returns t if the given YEAR is a leap year and nil otherwise.

MONDAY-OF-WEEK (WEEK YEAR)

Return (values year month day) where month and day correspond to the Monday of WEEK in YEAR

NORMALIZE-DHMS (DAY HOUR MIN SEC)

This function takes four arbitrary values for days, hours, minutes and seconds (which may have different signs) and renormalizes them so that the values for hours, minutes and seconds will lie in the ranges [-23..23], [-59..59] and [-59..59], respectively, and so that they have the same sign.

NOW

This function returns (hour minute second) for right now.

NTH-WEEKDAY-OF-MONTH-YEAR (YEAR MONTH DOW N)

This function returns the (year month day) of the N-th day of week DOW in the given MONTH and YEAR; such as, for example, the 3rd Thursday of a given month and year. DOW is not CL conform.

STANDARD-TO-BUSINESS (YEAR MONTH DAY)

This function converts a given date from standard notation YEAR MONTH DAY to business notation year week dow. DOW is not CL conform.

SYSTEM-CLOCK (GMT TIME)

This function returns (values year month day hour min sec doy dow dst) based on current system clock. DOW is not CL conform.

THIS-YEAR

This function returns the current year in localtime.

TODAY

This function returns (year month day) for today.

TODAY-AND-NOW

This function returns (year month day hour minute second) for the current date and time.

WEEK-NUMBER (YEAR MONTH DAY)

This function returns the number of the week of the given Y M D lies in. If the given date lies in the LAST week of the PREVIOUS year, 0 is returned.

WEEK-OF-YEAR (YEAR MONTH DAY)

Return (values week year) where week is the week number of YEAR

WEEKS-IN-YEAR (YEAR)

This function returns the number of weeks in the given YEAR, i.e., either 52 or 53.

YEAR-TO-DAYS (YEAR)

Returns the number of days for YEAR since 1 Jan 1.

Undocumented

GMTIME

LOCALTIME

TOMORROW

VALID-MONTH-P (MONTH)

VALID-YEAR-P (YEAR)

YESTERDAY

Private

NORMALIZE-RANGES (DD DH DM DS)

Internal fn for normalize-dhms. Returns the normalized (values DD DH DM DS). This function prevents overflow errors on systems with short longs (e.g. 32-bits) (If need be for CL ???).

NORMALIZE-SIGNS (DD DH DM DS)

Internal fn for normalize-dhms.

NORMALIZE-TIME (DD DH DM DS)

Internal fn for normalize-dhms. Returns the normalized (values DD DH DM DS).

VARIABLE

Public

Undocumented

*LANGUAGE*

Private

CENTURY-OF-EPOC

Century of reference (epoc)

EOPOC

reference year (epoc)

YEAR-OF-EPOC

Year of reference (epoc)

Undocumented

DAY-OF-WEEK-ABBREVIATION

DAY-OF-WEEK-TO-TEXT

DAYS-IN-MONTH-ARR

DAYS-IN-YEAR-ARR

LANGUAGE-TO-TEXT

LANGUAGES

LONG-FORMAT

MONTH-TO-TEXT