chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Request for new egg: date-info


From: Alaric Snell-Pym
Subject: [Chicken-users] Request for new egg: date-info
Date: Sun, 13 Apr 2008 15:45:24 +0100


Hello,

I've wrapped some C code I wrote ages ago to do date manipulation as
a Chicken foreign thingy, as I wanted to use it for my scheme
accounting tool.

I'd like to share it with all who might also find it useful.
Basically, you construct a date object from a date in one of the two
supported formats (year/month/day or julian day number), then it
provides a set of accessors to get information about the date.

These are grouped into four date systems:

 - The julian day number of the date

 - The year, the month, the day of the month, and the number of days
in this month

 - The day of the year (as in, 1st Jan is 1, and it counts up from
there), and the number of days in the year (and a leap year boolean,
as another way of expressing the same information)

 - The ISO weekdate year, week-of-the-year, and day-of-the-week.

What it lacks to make it *really* complete would be a how-many-ISO-
weeks-are-in-this-ISO-weekyear function, and a constructor to create
a date object from an ISO date. They shouldn't be too hard to do,
I've just never needed them myself so have not gotten around to either.

The information it provides are enough to do all sorts of useful date
arithmetic - find the date of the next Monday after a given date
(find the day-of-week, work out how many days until next Monday, then
create a new date from the JDN of the target date plus that many
days). Days between any two dates can be computed by subtracting
their JDNs. Any date can be converted to a JDN, a number of days
added or subtracted, then converted to a y/m/d date again to find the
date N days before or after any date, etc.

I suggest the egg name "date-info" to reflect its passive take-a-date-
and-return-information-about-it nature, and ask that I be given a
nice directory in the repository to put it in (I already have an svn
account)!

Thanks,

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/?author=4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]