From: Julien S. <Jul...@lr...> - 2004-10-29 15:18:27
|
On Fri, 29 Oct 2004, Richard Jones wrote: > On Fri, Oct 29, 2004 at 04:31:15PM +0200, Julien Signoles wrote: > > # let business_of_standard d = week d, day_of_week d;; > > val business_of_standard : Date.t -> int * Date.day = <fun> > > Actually, come to think of it, even if you sort out the year problem > this still may not work. You'll need to have a look at how it's > implemented in GregorianDate. I checked that implementation for > correctness pretty thoroughly. Concerning the implementation problem: business_of_standard is not so difficult but, yes, standard_of_business is a little bit more technical. So I will add these functions in calendar before the next release. Concerning the "correctness" problem: I think that this problem is not exactly the same in calendar: all the dates are correct (except a special case) if you follow the "coercion rule" explained at the beginning of the module Date: ========== If a date d does not exists and if d_bef (resp. d_aft) is the last (resp. first) existing date before (resp. after) d, d is automatically coerced to d_aft + d - d_bef - 1. For example, both dates "February 29th, 2003" and "February 30th, 2003" do not exist and they are coerced respectively to the date "Mars 1st, 2003" and "Mars 2nd, 2003". This rule is called the coercion rule. As an exception to the coercion rule, the date belonging to [October 5th, 1582; October 14th, 1582] do not exist and an Undefined exception is raised if you attempt to create such a date. Those dropped days correspond to the change from the Julian to the Gregorian calendar. ========== This rule is a choice. So one can discuss it for a long time ;-). It was made because all the algorithms correctly work with it. However I think I can have two versions of make: * a "safe" version as you have in GregorianDate * an "unsafe" version as I have yet in calendar (but, of course, safe as regards the coercion rule) I think that I will provide both versions in the next release. -- Julien |