Intended use as a general 'all-day' date calculus library.
Ver: 0.2
Renamed the functions by leaving out the leading 'date-calc-'.Thanks to Luigi Panzeri aka Matley for pointing to this.
Usage: (load "date-calc.lisp") generates the package 'date-calc'.
The CVS repository.
The following LISP functions are exported:
(listed with the corresponding PERL fn)
LISP(PARAMETER) => Return value(s) |
PERL: |
*language* Global Variable in Package => Integer | Language |
decode-day-of-week (STR) => DOW | Decode_Day_of_Week |
decode-month (STR) => M | Decode_Month |
decode-language (N) => STR | Decode_Language |
fixed-window (YY) => YYYY | fixed_window |
center (str width) => width/2 str width/2 | center |
valid-year-p (Y) => T/NIL | Valid_Year |
valid-month-p (M) => T/NIL | Valid_Month |
leap-year (Y) => 1/0 | leap_year |
leap-year-p (Y) => T/NIL | |
days-in-month (Y M) => D | Days_in_Month |
days-in-year (Y &optional M) => D | Days_in_Year |
check-date (Y M D) => 1/0 | check_date |
check-business-p (Y W DOW) => T/NIL | Check_Business |
check-time-p (H M S) => T/NIL | Check_Time |
day-of-year (Y M D) => D | Day_of_Year |
date-to-days (Y M D) => D | Date_of_Days |
day-of-week (Y M D) => DOW | Day_of_Week |
weeks-in-year (Y) => W | Weeks_in_Year |
delta-days (Y1 M1 D1 Y2 M2 D2) => D | Delta_Days |
week-number (Y M D) => W | Week_Number |
week-of-year (Y M D) => W Y | Week_of_Year |
add-delta-days (Y M D dD) => Y M D | Add_Delta_Days |
monday-of-week (W Y) => Y M D | Monday_of_Week |
nth-weekday-of-month-year (Y M DOW n) => Y M D | Nth_Weekday_of_Month_Year |
standard-to-business (Y M D) => Y W DOW | Standard_to_Business |
business-to-standard (Y W DOW) => Y M D | Business_to_Standard |
delta-hms (H1 M1 S1 H2 M2 S2) => H M S | Delta_HMS |
delta-dhms (D1 H1 M1 S1 D2 H2 M2 S2) => D H M S | Delta_DHMS |
delta-ymd (Y1 M1 D1 Y2 M2 D2) => Y M D | Delta_YMD |
delta-ymdhms (Y1 M1 D1 H1 M1 S1 Y2 D2 H2 M2 S2) => Y M D H M S | Delta_YMDHMS |
normalize-dhms (D H M S) => D H M S | Normalize_DHMS |
add-delta-dhms (Y M D H M S dD dH dM dS) => Y M D H M S | Add_Delta_DHMS |
add-year-month (Y M dY dM) => Y M | Add_Year_Month |
add-delta-ym (Y M D dY dM) => Y M D | Add_Delta_YM |
add-delta-ymd (Y M D dY dM dD) => Y M D | Add_Delta_YMD |
add-delta-ymdhms (Y M D H M S dY dM dD dH dM dS) => Y M D H M S | Add_Delta_YMDHMS |
today NIL => Y M D | Today |
now NIL => H M S | Now |
today-and-now NIL => Y M D H M S | Today_and_Now |
this-year NIL => Y | Add_Delta_Days |
date-to-text (Y M D) => STR | Date_to_Text |
date-to-text-long (Y M D) => STR | Date_to_Text_Long |
iso-lc (char) => char | ISO_LC |
iso-uc (char) => char | ISO_UC |
year-to-days (Y) => D | |
yesterday NIL => Y M D | |
tomorrow NIL => Y M D | |
cl-day-of-week NIL => D | |
cl-check-business-p (Y W DOW) => T/NIL | |
cl-nth-weekday-of-month-year (Y M D) => DOW | |
cl-decode-day-of-week (STR) => DOW | |
cl-standard-to-business (Y M D) => Y W DOW | |
cl-business-to-standard (Y W DOW) => Y M D |
Y=Year,M=Month/Minute,D=Day,H=Hour,S=Second,W=Week,DOW=Day of Week,STR=STRING (all Integer).
Some lisp functions do not have a corresponding Perl function.Especially the 'cl-...' functions which do accept or return the CL Weekday numbering scheme i.e Monday=0. See CLHS 25.1.4.1
Description of the functions:*language* Global Variable in Package | 0=Default, 1=English, 2=Francais, 3=Deutsch, 4=Espanol, 5=Portugues, 6=Nederlands, 7=Italiano, 8=Norsk, 9=Svenska, 10=Dansk, 11=suomi |
decode-day-of-week (STR) | Reads in a string and returns the DOW as integer with respect to *language*. |
decode-month (STR) | Returns number of month. STR can partially name the month according to *language*. Computes a (search ...:test #'char-equal) |
decode-language (N) | Reads in the Lang as NUM and returns the corresponding textual representation. |
fixed-window (YY) | Convert two digit YEAR to four digit YEAR; YEAR<=70 -> 2000+YEAR; YEAR<100&&>70 -> 1900+YEAR. |
center (str width) | Return a string that is WIDTH long with STRING centered in it. |
valid-year-p (Y) | Checks if Y >= 1 |
valid-month-p (M) | Checks if Y<=12 && Y>=1 |
leap-year (Y) | Returns 1 if Y is a leap year. Else 0. |
leap-year-p (Y) | Returns T if Y is a leap year. Else NIL. |
days-in-month (Y M) | Returns the number of days in MONTH of YEAR. |
days-in-year (Y &optional M) | 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. |
check-date (Y M D) | This function returns t if the given three numerical values YEAR MONTH DAY constitute a valid date, and nil otherwise. |
check-business-p (Y W 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-time-p (H M S) | This function returns t if the given three numerical values HOUR MIN SEC constitute a valid time, and nil otherwise. |
day-of-year (Y M D) | 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. |
date-to-days (Y M D) | This function returns the (absolute) number of the day of the given date, where counting starts at the 1.Jan 1. |
day-of-week (Y M D) | Returns the Number of the Day of the Week. Monday=1. |
weeks-in-year (Y) | Returns the number of weeks in YEAR. |
delta-days (Y1 M1 D1 Y2 M2 D2) | Returns the diff of the two YMD values in Days. |
week-number (Y M D) | 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 (Y M D) | Returns WEEK YEAR where week is the week number of YEAR. |
add-delta-days (Y M D dD) | Returns YMD = YMD + dD. dD can be neagtive. |
monday-of-week (W Y) | Return YEAR MONTH DAY corresponding to the Monday of WEEK in YEAR. |
nth-weekday-of-month-year (Y M DOW n) | This function returns the YEAR MONTH DAY of the N-th day of week DOW is 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 (Y M D) | Returns the Business date of Y M D. |
business-to-standard (Y W DOW) | Returns the standard date of Y M DOW. |
delta-hms (H1 M1 S1 H2 M2 S2) | This function returns H M S as the difference of H1 M1 S1 and H2 M2 S2. |
delta-dhms (D1 H1 M1 S1 D2 H2 M2 S2) | Returns D H M S as the difference of D1 H1 M1 S1 and D2 H2 M2 S2. |
delta-ymd (Y1 M1 D1 Y2 M2 D2) | Returns Y M D as the difference of Y1 M1 D1 and Y2 M2 D2. |
delta-ymdhms (Y1 M1 D1 H1 M1 S1 Y2 D2 H2 M2 S2) | Returns Y M D H M S as the difference of Y1 M1 D1 H1 M1 S1 and Y2 M2 D2 H2 M2 S2. |
normalize-dhms (D H M S) | 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 (Except for D). |
add-delta-dhms (Y M D H M S 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: Y M D H M S. |
add-year-month (Y M dY dM) | Returns YM=Y+dY+M+dM. |
add-delta-ym (Y M D dY dM) | Returns YM=YM+dY+dM+D |
add-delta-ymd (Y M D dY dM dD) | Returns YMD=YMD+dY+dM+dD |
add-delta-ymdhms (Y M D H M S dY dM dD dH dM dS) | Returns YMDHMS=YMDHMS+dY+dM+dD+dH+dM+dS |
today NIL | Returns YMD of Today. |
now NIL | Returns the time of now in HMS. |
today-and-now NIL | Returns Today and now in YMDHMS. |
this-year NIL | Returns this year. |
date-to-text (Y M D) | Returns a text representation of YMD with respect to *language*. |
date-to-text-long (Y M D) | Returns a longer text representation of YMD with respect to *language*. |
iso-lc (char) | Converts CHAR to ISO Lower Case. |
iso-uc (char) | Converts CHAR to ISO Upper Case. |
year-to-days (Y) | Returns the number of days for YEAR since 1 Jan 1. |
yesterday NIL | Returns YMD of Yesterday. |
tomorrow NIL | Returns YMD of tomorrow. |
cl-day-of-week NIL | Returns the DOW in CL notation. Monday=0. |
cl-check-business-p (Y W 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-nth-weekday-of-month-year (Y M D) | 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-decode-day-of-week (STR) | Returns number of weekday. STR can partially name the Weekday according to *language*. DOW is CL conform. |
cl-standard-to-business (Y M D) | Returns Business date in CL notation of given YMD. |
cl-business-to-standard (Y W DOW) | Returns the YMD of given Business date in CL notation. |