[Sorry - sent before I was done.]

I'm adding a "Date.add()" method to my JavaScript date library and wanted
some input on how it should work.

The function takes two arguments: "Amount" (the number of units to add or,
if negative, to subtract) and "DatePart" (the units to add).

Right now these are the rules I've got for dateparts:

"milliseconds": Unambiguous.  Add the amount directly.
"seconds": Unambiguous.  Add Amount * 1000 milliseconds.
"minutes": Unambiguous.  Add Amount * 1000 * 60 milliseconds.
"hours": Unambiguous.  Add Amount * 1000 * 60 * 60 milliseconds.
"days": Unambiguous.  Add Amount * 1000 * 60 * 60 * 24 milliseconds.
"weeks": Unambiguous.  Add Amount * 1000 * 60 * 60 * 24 * 7 milliseconds.
"months": Ambigious.

        Add the Amount of months. If the current day of month is not present
in the new month, make the new date the last day of the month.  In other
words if the date is January 31 and I add one month the resulting date would
be February 28 (or February 29th).

"years": Ambigious.

        Add the Amount of years.  If the current date is February 29th and
the new year is not a leap-year make the date February 28th.

First off does that sound good?  Are there any ambiguities that I've missed?
Perhaps for Week?

For week: should I really be just added blocks of seven days or should I be
adding blocks of "Sunday to Saturday" days and always resulting in the
beginning of the new week?

In other words as I have it now doing Date.add(1, "weeks") is the same as
Date.add(7, "days") - should it be?  Or should Date.add(1, "weeks") return
the next Sunday (add days until the week has changed)?

I'm also interested in adding other DateParts such as "Quarter" (same
questions as with Week: should it be simply three months or jump by actual
quarter), "BusinessDay" (would exclude Saturday and Sunday but would NOT be
smart enough to deal with holidays - I'm not getting into that kettle of
fish), "Business Week" (which I think would just be sets of 5 business days)
and perhaps even "Decades" and "Centuries".

Any thoughts?  Requests?

Jim Davis


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/cf_lists/message.cfm/forumid:5/messageid:210827
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5

Reply via email to