date stuff in gnucash

Terry tboldt@attglobal.net
Tue, 28 Nov 2000 19:30:31 -0500


On Mon, 27 Nov 2000, you wrote:
> OK.
> 
> I need some complex time/date manipulation functions to deal with
> budgeting.
> 
> So far it looks like there are two scheme files in the dist that deal
> with dates:
> 
> src/scm/date-utilities.scm
> src/scm/srfi/srfi-19.scm
> 
> srfi-19.scm doesn't contain all of the srfi #19 example implementation
> and I was wondering why.
> 
> Anyway.  Here's the notes I have so far on what I need:
> 
> Types of dates:
> 
> Abstract: Not a real date or relative date.  This is for things like
>  "The last monday in a month".  It's a date, but it's not a real date.
> Relative: A date diff.  "Two weeks later".  "Two weeks earlier" etc.
> Absolute: A real date.
> 
> There are also ranges of each date #<'Range #<'Abstract "three days
> before end of month"> #<'Abstract "two days after begining of month">>
> etc.
> 
> Plus all the fun comparison, adding, subtracting, dealies.
> 
> Leaving out a bit here that isn't necessary yet.
> 
> Any thoughts?  Anything missing?
> 
> Jim
> 
> -- 

I have a package that I have been using for quite a few years now, written in
QTAwk - almost C - which has the following functions available for date
computations:

1: Weekday_Following - returns the number of days from the date passed (year,
month, day) to the weekday specified, 0 to 6, 0 == Sunday, 6 == Saturday, and
following the date passed. For Example, specifying 1999-4-1, yyyy-mm-dd,
Thursday, and specifying Sunday as the weekday wanted, 3 is returned.

2: Weekday Preceeding - returns the number of days from the date passed (year,
month, day) to the weekday specified, 0 to 6 0 == Sunday, 6 == Saturday, and
preceeding the date passed. For Example, specifying 1999-4-1, yyyy-mm-dd,
Thursday, and specifying Sunday as the weekday wanted, 4 is returned.

3: Weeknumber - returns week number of date passed.

4: Weekday - returns week day of date passed, 0 == Sunday, 6 == Saturday

5: MDY_to_DOC - returns day of century number

6: month_day_date - returns day of month for day passed, e.g., want day of
month for the second Thursday in September,  1996 - returns 12.
Sept. 12, 1996 is the second Thursday of the month

7:  last_dow_of_month - reurns day of month for day-of-week passed as the last
day-of-week for that month, e.g., for last thursday in month of October, 1996 -
returns 31.
Oct 31, 1996 is the last Thursday of the month

These functions rely on the "jdn" function which returns the astronomical
"Julian Day Number", JDN, of a specified date and the "caln" function which is
the inverse of the "jdn" function, returning the year, month and day of a
specified JDN. The functions have been tested from jdn == 0 == Monday, 1 Jan
4713 BC to several million years from the present time. Another function is
avaliable which will automatically switch between the appropriate calenders as
necessary, i.e., Gregorian/Julian.  The "jdn" and "caln" functions make most, if
not all, date computations as easy as addition/sudbtraction of integers. If you
desire this package I can send it to you.