date stuff in gnucash
Tue, 28 Nov 2000 00:49:08 -0800
James LewisMoss writes:
> An abstract date points to a real date, but not a particular one.
> "Last monday in a month" has a real occurrence (12 a year in fact). A
> relative date isn't a real date. It's a difference. You can't say
> "give me an absolute date that conforms to this relative date". You
> can with an abstract date.
I tend to think of abstract dates as functions from absolute dates
to absolute dates. So, "last monday in a month" would be a function
that, given a date X, returns the date of the last monday of the
month in which X occurs.
A relative date is a function from absolute dates to pairs of
absolute dates. So, "2 weeks" would be a function that, given a
date X, returns (Y, Z) where Y is 2 weeks before X and Z is two
weeks after X.
You can turn a relative date into an abstract date by just
projecting the result to either the first or second member
of the pair, depending on whether you want to add or subtract.
In this conceptualization, you can combine abstract dates
arbitrarily using funcition composition. And adding a relative
date to an abstract date is just projection and composition.
I think this conceptualization might be usefuly adapted to an
implementation, given the ease with which functions are
manipulated in scheme.