/[cl-date-calc]/cl-date-calc/index.html
ViewVC logotype

Contents of /cl-date-calc/index.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Wed Feb 1 15:45:50 2006 UTC (8 years, 2 months ago) by hschroter
Branch: cl-date-calc, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/html
cl-date-calc
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><body><h3>Date-Calc Lisp (A port from Date::Calc Perl).</h3><div>Heiko Schr&ouml;ter, 2005, schroete at iup physik uni-bremen de</div><p>Intended use as a general 'all-day' date calculus library.</p><p>Ver: 0.2</p><p>Renamed the functions by leaving out the leading 'date-calc-'.Thanks to Luigi Panzeri aka Matley for pointing to this.</p><p>Usage: (load "date-calc.lisp") generates the package 'date-calc'.</p><a href='../lisp/date-calc.lisp'><b>The Package: date-calc.lisp</b><br /><br /></a><a href='../lisp/date-calc-0.2.tar.gz'><b>The ASDF installable package.</b><br /><br /></a><a href='../lisp/test-date-calc.lisp'><b>A test script for cmucl and sbcl: test-date-calc.lisp</b></a><div>(Compares against PERL Date::Calc. Needs to be installed.)</div><p>The following LISP functions are exported:<br>(listed with the corresponding PERL fn)</p><table border='0' cellpadding='2'><tr align='center'><td bgcolor='pink'><p>LISP(PARAMETER) => Return value(s)</p></td><td bgcolor='lightgray'><p>PERL:</p></td></tr><tr align='left'><td bgcolor='pink'>*language* Global Variable in Package => Integer</td><td bgcolor='lightgray'>Language</td></tr><tr align='left'><td bgcolor='pink'>decode-day-of-week (STR) => DOW</td><td bgcolor='lightgray'>Decode_Day_of_Week</td></tr><tr align='left'><td bgcolor='pink'>decode-month (STR) => M</td><td bgcolor='lightgray'>Decode_Month</td></tr><tr align='left'><td bgcolor='pink'>decode-language (N) => STR</td><td bgcolor='lightgray'>Decode_Language</td></tr><tr align='left'><td bgcolor='pink'>fixed-window (YY) => YYYY</td><td bgcolor='lightgray'>fixed_window</td></tr><tr align='left'><td bgcolor='pink'>center (str width) => width/2 str width/2</td><td bgcolor='lightgray'>center</td></tr><tr align='left'><td bgcolor='pink'>valid-year-p (Y) => T/NIL</td><td bgcolor='lightgray'>Valid_Year</td></tr><tr align='left'><td bgcolor='pink'>valid-month-p (M) => T/NIL</td><td bgcolor='lightgray'>Valid_Month</td></tr><tr align='left'><td bgcolor='pink'>leap-year (Y) => 1/0</td><td bgcolor='lightgray'>leap_year</td></tr><tr align='left'><td bgcolor='pink'>leap-year-p (Y) => T/NIL</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>days-in-month (Y M) => D</td><td bgcolor='lightgray'>Days_in_Month</td></tr><tr align='left'><td bgcolor='pink'>days-in-year (Y &optional M) => D</td><td bgcolor='lightgray'>Days_in_Year</td></tr><tr align='left'><td bgcolor='pink'>check-date (Y M D) => 1/0</td><td bgcolor='lightgray'>check_date</td></tr><tr align='left'><td bgcolor='pink'>check-business-p (Y W DOW) => T/NIL</td><td bgcolor='lightgray'>Check_Business</td></tr><tr align='left'><td bgcolor='pink'>check-time-p (H M S) => T/NIL</td><td bgcolor='lightgray'>Check_Time</td></tr><tr align='left'><td bgcolor='pink'>day-of-year (Y M D) => D</td><td bgcolor='lightgray'>Day_of_Year</td></tr><tr align='left'><td bgcolor='pink'>date-to-days (Y M D) => D</td><td bgcolor='lightgray'>Date_of_Days</td></tr><tr align='left'><td bgcolor='pink'>day-of-week (Y M D) => DOW</td><td bgcolor='lightgray'>Day_of_Week</td></tr><tr align='left'><td bgcolor='pink'>weeks-in-year (Y) => W</td><td bgcolor='lightgray'>Weeks_in_Year</td></tr><tr align='left'><td bgcolor='pink'>delta-days (Y1 M1 D1 Y2 M2 D2) => D</td><td bgcolor='lightgray'>Delta_Days</td></tr><tr align='left'><td bgcolor='pink'>week-number (Y M D) => W</td><td bgcolor='lightgray'>Week_Number</td></tr><tr align='left'><td bgcolor='pink'>week-of-year (Y M D) => W Y</td><td bgcolor='lightgray'>Week_of_Year</td></tr><tr align='left'><td bgcolor='pink'>add-delta-days (Y M D dD) => Y M D</td><td bgcolor='lightgray'>Add_Delta_Days</td></tr><tr align='left'><td bgcolor='pink'>monday-of-week (W Y) => Y M D</td><td bgcolor='lightgray'>Monday_of_Week</td></tr><tr align='left'><td bgcolor='pink'>nth-weekday-of-month-year (Y M DOW n) => Y M D</td><td bgcolor='lightgray'>Nth_Weekday_of_Month_Year</td></tr><tr align='left'><td bgcolor='pink'>standard-to-business (Y M D) => Y W DOW</td><td bgcolor='lightgray'>Standard_to_Business</td></tr><tr align='left'><td bgcolor='pink'>business-to-standard (Y W DOW) => Y M D</td><td bgcolor='lightgray'>Business_to_Standard</td></tr><tr align='left'><td bgcolor='pink'>delta-hms (H1 M1 S1 H2 M2 S2) => H M S</td><td bgcolor='lightgray'>Delta_HMS</td></tr><tr align='left'><td bgcolor='pink'>delta-dhms (D1 H1 M1 S1 D2 H2 M2 S2) => D H M S</td><td bgcolor='lightgray'>Delta_DHMS</td></tr><tr align='left'><td bgcolor='pink'>delta-ymd (Y1 M1 D1 Y2 M2 D2) => Y M D</td><td bgcolor='lightgray'>Delta_YMD</td></tr><tr align='left'><td bgcolor='pink'>delta-ymdhms (Y1 M1 D1 H1 M1 S1 Y2 D2 H2 M2 S2) => Y M D H M S</td><td bgcolor='lightgray'>Delta_YMDHMS</td></tr><tr align='left'><td bgcolor='pink'>normalize-dhms (D H M S) => D H M S</td><td bgcolor='lightgray'>Normalize_DHMS</td></tr><tr align='left'><td bgcolor='pink'>add-delta-dhms (Y M D H M S dD dH dM dS) => Y M D H M S</td><td bgcolor='lightgray'>Add_Delta_DHMS</td></tr><tr align='left'><td bgcolor='pink'>add-year-month (Y M dY dM) => Y M</td><td bgcolor='lightgray'>Add_Year_Month</td></tr><tr align='left'><td bgcolor='pink'>add-delta-ym (Y M D dY dM) => Y M D</td><td bgcolor='lightgray'>Add_Delta_YM</td></tr><tr align='left'><td bgcolor='pink'>add-delta-ymd (Y M D dY dM dD) => Y M D</td><td bgcolor='lightgray'>Add_Delta_YMD</td></tr><tr align='left'><td bgcolor='pink'>add-delta-ymdhms (Y M D H M S dY dM dD dH dM dS) => Y M D H M S</td><td bgcolor='lightgray'>Add_Delta_YMDHMS</td></tr><tr align='left'><td bgcolor='pink'>today NIL => Y M D</td><td bgcolor='lightgray'>Today</td></tr><tr align='left'><td bgcolor='pink'>now NIL => H M S</td><td bgcolor='lightgray'>Now</td></tr><tr align='left'><td bgcolor='pink'>today-and-now NIL => Y M D H M S</td><td bgcolor='lightgray'>Today_and_Now</td></tr><tr align='left'><td bgcolor='pink'>this-year NIL => Y</td><td bgcolor='lightgray'>Add_Delta_Days</td></tr><tr align='left'><td bgcolor='pink'>date-to-text (Y M D) => STR</td><td bgcolor='lightgray'>Date_to_Text</td></tr><tr align='left'><td bgcolor='pink'>date-to-text-long (Y M D) => STR</td><td bgcolor='lightgray'>Date_to_Text_Long</td></tr><tr align='left'><td bgcolor='pink'>iso-lc (char) => char</td><td bgcolor='lightgray'>ISO_LC</td></tr><tr align='left'><td bgcolor='pink'>iso-uc (char) => char</td><td bgcolor='lightgray'>ISO_UC</td></tr><tr align='left'><td bgcolor='pink'>year-to-days (Y) => D</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>yesterday NIL => Y M D</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>tomorrow NIL => Y M D</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-day-of-week NIL => D</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-check-business-p (Y W DOW) => T/NIL</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-nth-weekday-of-month-year (Y M D) => DOW</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-decode-day-of-week (STR) => DOW</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-standard-to-business (Y M D) => Y W DOW</td><td bgcolor='lightgray'></td></tr><tr align='left'><td bgcolor='pink'>cl-business-to-standard (Y W DOW) => Y M D</td><td bgcolor='lightgray'></td></tr></table><p>Y=Year,M=Month/Minute,D=Day,H=Hour,S=Second,W=Week,DOW=Day of Week,STR=STRING (all Integer).</p><p>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</p><b>Description of the functions:</b><table border='0' cellpadding='2'><tr align='left'><td bgcolor='lightgray'><b>*language* Global Variable in Package</b></td><td bgcolor='lightgray'>0=Default, 1=English, 2=Francais, 3=Deutsch, 4=Espanol, 5=Portugues, 6=Nederlands, 7=Italiano, 8=Norsk, 9=Svenska, 10=Dansk, 11=suomi</td></tr><tr align='left'><td bgcolor='lightgray'><b>decode-day-of-week (STR)</b></td><td bgcolor='lightgray'>Reads in a string and returns the DOW as integer with respect to *language*.</td></tr><tr align='left'><td bgcolor='lightgray'><b>decode-month (STR)</b></td><td bgcolor='lightgray'>Returns number of month. STR can partially name the month according to *language*. Computes a (search ...:test #'char-equal)</td></tr><tr align='left'><td bgcolor='lightgray'><b>decode-language (N)</b></td><td bgcolor='lightgray'>Reads in the Lang as NUM and returns the corresponding textual representation.</td></tr><tr align='left'><td bgcolor='lightgray'><b>fixed-window (YY)</b></td><td bgcolor='lightgray'>Convert two digit YEAR to four digit YEAR; YEAR<=70 -> 2000+YEAR; YEAR<100&&>70 -> 1900+YEAR.</td></tr><tr align='left'><td bgcolor='lightgray'><b>center (str width)</b></td><td bgcolor='lightgray'>Return a string that is WIDTH long with STRING centered in it.</td></tr><tr align='left'><td bgcolor='lightgray'><b>valid-year-p (Y)</b></td><td bgcolor='lightgray'>Checks if Y >= 1</td></tr><tr align='left'><td bgcolor='lightgray'><b>valid-month-p (M)</b></td><td bgcolor='lightgray'>Checks if Y<=12 && Y>=1</td></tr><tr align='left'><td bgcolor='lightgray'><b>leap-year (Y)</b></td><td bgcolor='lightgray'>Returns 1 if Y is a leap year. Else 0.</td></tr><tr align='left'><td bgcolor='lightgray'><b>leap-year-p (Y)</b></td><td bgcolor='lightgray'>Returns T if Y is a leap year. Else NIL.</td></tr><tr align='left'><td bgcolor='lightgray'><b>days-in-month (Y M)</b></td><td bgcolor='lightgray'>Returns the number of days in MONTH of YEAR.</td></tr><tr align='left'><td bgcolor='lightgray'><b>days-in-year (Y &optional M)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>check-date (Y M D)</b></td><td bgcolor='lightgray'>This function returns t if the given three numerical values YEAR MONTH DAY constitute a valid date, and nil otherwise.</td></tr><tr align='left'><td bgcolor='lightgray'><b>check-business-p (Y W DOW)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>check-time-p (H M S)</b></td><td bgcolor='lightgray'>This function returns t if the given three numerical values HOUR MIN SEC constitute a valid time, and nil otherwise.</td></tr><tr align='left'><td bgcolor='lightgray'><b>day-of-year (Y M D)</b></td><td bgcolor='lightgray'>This function returns the sum of the number of days in the months starting with January up to and including MONTH in
2 the given year YEAR. 0 on failure.</td></tr><tr align='left'><td bgcolor='lightgray'><b>date-to-days (Y M D)</b></td><td bgcolor='lightgray'>This function returns the (absolute) number of the day of the given date, where counting starts at the 1.Jan 1.</td></tr><tr align='left'><td bgcolor='lightgray'><b>day-of-week (Y M D)</b></td><td bgcolor='lightgray'>Returns the Number of the Day of the Week. Monday=1.</td></tr><tr align='left'><td bgcolor='lightgray'><b>weeks-in-year (Y)</b></td><td bgcolor='lightgray'>Returns the number of weeks in YEAR.</td></tr><tr align='left'><td bgcolor='lightgray'><b>delta-days (Y1 M1 D1 Y2 M2 D2)</b></td><td bgcolor='lightgray'>Returns the diff of the two YMD values in Days.</td></tr><tr align='left'><td bgcolor='lightgray'><b>week-number (Y M D)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>week-of-year (Y M D)</b></td><td bgcolor='lightgray'>Returns WEEK YEAR where week is the week number of YEAR.</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-delta-days (Y M D dD)</b></td><td bgcolor='lightgray'>Returns YMD = YMD + dD. dD can be neagtive.</td></tr><tr align='left'><td bgcolor='lightgray'><b>monday-of-week (W Y)</b></td><td bgcolor='lightgray'>Return YEAR MONTH DAY corresponding to the Monday of WEEK in YEAR.</td></tr><tr align='left'><td bgcolor='lightgray'><b>nth-weekday-of-month-year (Y M DOW n)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>standard-to-business (Y M D)</b></td><td bgcolor='lightgray'>Returns the Business date of Y M D.</td></tr><tr align='left'><td bgcolor='lightgray'><b>business-to-standard (Y W DOW)</b></td><td bgcolor='lightgray'>Returns the standard date of Y M DOW.</td></tr><tr align='left'><td bgcolor='lightgray'><b>delta-hms (H1 M1 S1 H2 M2 S2)</b></td><td bgcolor='lightgray'>This function returns H M S as the difference of H1 M1 S1 and H2 M2 S2.</td></tr><tr align='left'><td bgcolor='lightgray'><b>delta-dhms (D1 H1 M1 S1 D2 H2 M2 S2)</b></td><td bgcolor='lightgray'>Returns D H M S as the difference of D1 H1 M1 S1 and D2 H2 M2 S2.</td></tr><tr align='left'><td bgcolor='lightgray'><b>delta-ymd (Y1 M1 D1 Y2 M2 D2)</b></td><td bgcolor='lightgray'>Returns Y M D as the difference of Y1 M1 D1 and Y2 M2 D2.</td></tr><tr align='left'><td bgcolor='lightgray'><b>delta-ymdhms (Y1 M1 D1 H1 M1 S1 Y2 D2 H2 M2 S2)</b></td><td bgcolor='lightgray'>Returns Y M D H M S as the difference of Y1 M1 D1 H1 M1 S1 and Y2 M2 D2 H2 M2 S2.</td></tr><tr align='left'><td bgcolor='lightgray'><b>normalize-dhms (D H M S)</b></td><td bgcolor='lightgray'>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).</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-delta-dhms (Y M D H M S dD dH dM dS)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-year-month (Y M dY dM)</b></td><td bgcolor='lightgray'>Returns YM=Y+dY+M+dM.</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-delta-ym (Y M D dY dM)</b></td><td bgcolor='lightgray'>Returns YM=YM+dY+dM+D</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-delta-ymd (Y M D dY dM dD)</b></td><td bgcolor='lightgray'>Returns YMD=YMD+dY+dM+dD</td></tr><tr align='left'><td bgcolor='lightgray'><b>add-delta-ymdhms (Y M D H M S dY dM dD dH dM dS)</b></td><td bgcolor='lightgray'>Returns YMDHMS=YMDHMS+dY+dM+dD+dH+dM+dS</td></tr><tr align='left'><td bgcolor='lightgray'><b>today NIL</b></td><td bgcolor='lightgray'>Returns YMD of Today.</td></tr><tr align='left'><td bgcolor='lightgray'><b>now NIL</b></td><td bgcolor='lightgray'>Returns the time of now in HMS.</td></tr><tr align='left'><td bgcolor='lightgray'><b>today-and-now NIL</b></td><td bgcolor='lightgray'>Returns Today and now in YMDHMS.</td></tr><tr align='left'><td bgcolor='lightgray'><b>this-year NIL</b></td><td bgcolor='lightgray'>Returns this year.</td></tr><tr align='left'><td bgcolor='lightgray'><b>date-to-text (Y M D)</b></td><td bgcolor='lightgray'>Returns a text representation of YMD with respect to *language*.</td></tr><tr align='left'><td bgcolor='lightgray'><b>date-to-text-long (Y M D)</b></td><td bgcolor='lightgray'>Returns a longer text representation of YMD with respect to *language*.</td></tr><tr align='left'><td bgcolor='lightgray'><b>iso-lc (char)</b></td><td bgcolor='lightgray'>Converts CHAR to ISO Lower Case.</td></tr><tr align='left'><td bgcolor='lightgray'><b>iso-uc (char)</b></td><td bgcolor='lightgray'>Converts CHAR to ISO Upper Case.</td></tr><tr align='left'><td bgcolor='lightgray'><b>year-to-days (Y)</b></td><td bgcolor='lightgray'>Returns the number of days for YEAR since 1 Jan 1.</td></tr><tr align='left'><td bgcolor='lightgray'><b>yesterday NIL</b></td><td bgcolor='lightgray'>Returns YMD of Yesterday.</td></tr><tr align='left'><td bgcolor='lightgray'><b>tomorrow NIL</b></td><td bgcolor='lightgray'>Returns YMD of tomorrow.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-day-of-week NIL</b></td><td bgcolor='lightgray'>Returns the DOW in CL notation. Monday=0.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-check-business-p (Y W DOW)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-nth-weekday-of-month-year (Y M D)</b></td><td bgcolor='lightgray'>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.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-decode-day-of-week (STR)</b></td><td bgcolor='lightgray'>Returns number of weekday. STR can partially name the Weekday according to *language*. DOW is CL conform.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-standard-to-business (Y M D)</b></td><td bgcolor='lightgray'>Returns Business date in CL notation of given YMD.</td></tr><tr align='left'><td bgcolor='lightgray'><b>cl-business-to-standard (Y W DOW)</b></td><td bgcolor='lightgray'>Returns the YMD of given Business date in CL notation.</td></tr></table><br /><a href='../lisp/index.lisp'><b>Page created with cl-who.</b></a></body></html>

  ViewVC Help
Powered by ViewVC 1.1.5