## [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations

 [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Julien Signoles - 2004-10-29 14:31:26 ```> On Fri, Oct 29, 2004 at 03:38:36PM +0200, Julien Signoles wrote: > > (a) those dealing with the "business week"; > > (b) nth_weekday_of_month; > > (c) the optional parameter ?month of days_in_year. > > But (b) and (c) will be available in the next release of calendar (soon !). > > At this day, I don't understand what is a "business week" :-(. > > Business weeks are vital for me. They're the whole reason I ported > Date::Calc in the first place. ok. I've seen again what is the business week and now I understand it :-). With GregorianDate, you have: # business_of_standard (2004, 12, 31);; - : (int * int) * int = ((2004, 53), 5) # business_of_standard (2003, 12, 31);; - : (int * int) * int = ((2004, 1), 3) With the module Date of calendar, you have: # let business_of_standard d = week d, day_of_week d;; val business_of_standard : Date.t -> int * Date.day = # business_of_standard (make 2004 12 31);; - : int * Date.day = (53, Fri) # business_of_standard (make 2003 12 31);; - : int * Date.day = (1, Wed) In my opinion, it is the same except that my version does not return the year. But it is possible to deduce it from the month and the week if necessary. Of course, it is possible to convert a Date.day value to an int (and conversely): # int_of_day Fri;; - : int = 5 So I think I have no functionality to add in calendar in order to deal with the business week but, please, tell me if I miss something. Julien -- mailto:Julien.Signoles@... ; http://www.lri.fr/~signoles "In theory, practice and theory are the same, but in practice they are different" (Larry McVoy) ```

 [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Julien Signoles - 2004-10-29 13:38:48 ```On Fri, 29 Oct 2004, Richard Jones wrote: > On Thu, Oct 28, 2004 at 11:33:30PM -0400, N. Owen Gunden wrote: > > Bump. Rich? > > Ah, sorry - this discussion moved to ocaml-lib-devel. I cc'd > caml-list, but it seems to have been spam filterered. > > http://sourceforge.net/mailarchive/forum.php?thread_id=5833296&forum_id=29880 ok. I didn't know this mailing list. I give my point of view. I try to be neutral ;-). 1) I download "cf" (version 0.4) and it seems that Cf_date is now called Cf_gregogian. 2) Cf_gregorian only defines 6 functions to convert a gregorian date to the Julian Day and conversely. These functions exists in the module Date of calendar. The calendar algorithms seem to be more efficient. However they only work in the date in [January, 1st 4713 BC; January 22th, 3268 AC] (against [12 Aug -2937947 CE; 27 Feb 2935093] for Cf_gregorian). It seems that these functions don't exist in GregorianDate. 3) Almost the functions of GregorianDate are available in the module Date of calendar except: (a) those dealing with the "business week"; (b) nth_weekday_of_month; (c) the optional parameter ?month of days_in_year. But (b) and (c) will be available in the next release of calendar (soon !). At this day, I don't understand what is a "business week" :-(. 4) Date in calendar deals with the gregorian calendar *and* the julian calendar. I think it is a pro in some applications and a cons in others... 5) Some operations of Date are not available in GregorianDate. In particular, a lot of arithmetics operations and the coercions with Unix (of the stdlib) are not provided. I think that these functions are useful. 5) Calendar doesn't only deal with dates but also with times. It also provides printers. More details in the doc: http://www.lri.fr/~signoles/prog/calendar/doc/index.html Conclusion: =========== I think calendar is more complete that GregorianDate and Cf_gregorian. I'm not sure but it also seems to be the oldest. First release and announce on the caml-list: 2003-07-11, see here: http://caml.inria.fr/archives/200307/msg00108.html Cheers, Julien -- mailto:Julien.Signoles@... ; http://www.lri.fr/~signoles "In theory, practice and theory are the same, but in practice they are different" (Larry McVoy) ```
 [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Richard Jones - 2004-10-29 13:53:43 Attachments: application/pgp-signature ```On Fri, Oct 29, 2004 at 03:38:36PM +0200, Julien Signoles wrote: > (a) those dealing with the "business week"; > (b) nth_weekday_of_month; > (c) the optional parameter ?month of days_in_year. > But (b) and (c) will be available in the next release of calendar (soon != ). > At this day, I don't understand what is a "business week" :-(. Business weeks are vital for me. They're the whole reason I ported Date::Calc in the first place. Rich. --=20 Richard Jones. http://www.annexia.org/ http://www.j-london.com/ >>> http://www.team-notepad.com/ - collaboration tools for teams <<< Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://winwinsales.co.uk/ - CRM consultancy ```
 [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Julien Signoles - 2004-10-29 14:31:26 ```> On Fri, Oct 29, 2004 at 03:38:36PM +0200, Julien Signoles wrote: > > (a) those dealing with the "business week"; > > (b) nth_weekday_of_month; > > (c) the optional parameter ?month of days_in_year. > > But (b) and (c) will be available in the next release of calendar (soon !). > > At this day, I don't understand what is a "business week" :-(. > > Business weeks are vital for me. They're the whole reason I ported > Date::Calc in the first place. ok. I've seen again what is the business week and now I understand it :-). With GregorianDate, you have: # business_of_standard (2004, 12, 31);; - : (int * int) * int = ((2004, 53), 5) # business_of_standard (2003, 12, 31);; - : (int * int) * int = ((2004, 1), 3) With the module Date of calendar, you have: # let business_of_standard d = week d, day_of_week d;; val business_of_standard : Date.t -> int * Date.day = # business_of_standard (make 2004 12 31);; - : int * Date.day = (53, Fri) # business_of_standard (make 2003 12 31);; - : int * Date.day = (1, Wed) In my opinion, it is the same except that my version does not return the year. But it is possible to deduce it from the month and the week if necessary. Of course, it is possible to convert a Date.day value to an int (and conversely): # int_of_day Fri;; - : int = 5 So I think I have no functionality to add in calendar in order to deal with the business week but, please, tell me if I miss something. Julien -- mailto:Julien.Signoles@... ; http://www.lri.fr/~signoles "In theory, practice and theory are the same, but in practice they are different" (Larry McVoy) ```
 [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Richard Jones - 2004-10-29 14:38:32 Attachments: application/pgp-signature ```On Fri, Oct 29, 2004 at 04:31:15PM +0200, Julien Signoles wrote: > With the module Date of calendar, you have: >=20 > # let business_of_standard d =3D week d, day_of_week d;; > val business_of_standard : Date.t -> int * Date.day =3D =2E.. except the difficult thing with business weeks is that business year is not necessarily equal to ordinary year. (Even PostgreSQL 7.4 gets this wrong). > # business_of_standard (make 2004 12 31);; > - : int * Date.day =3D (53, Fri) > # business_of_standard (make 2003 12 31);; > - : int * Date.day =3D (1, Wed) >=20 > In my opinion, it is the same except that my version does not return > the year. But it is possible to deduce it from the month and the week if > necessary. It's not ... or at least not trivially. Check out the implementation in GregorianDate. Rich. --=20 Richard Jones. http://www.annexia.org/ http://www.j-london.com/ >>> http://www.team-notepad.com/ - collaboration tools for teams <<< Merjis Ltd. http://www.merjis.com/ - improving website return on investment Write Apache modules in OCaml - http://www.merjis.com/developers/mod_caml ```
 Re: [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Richard Jones - 2004-10-29 14:42:38 Attachments: application/pgp-signature ```On Fri, Oct 29, 2004 at 04:31:15PM +0200, Julien Signoles wrote: > # let business_of_standard d =3D week d, day_of_week d;; > val business_of_standard : Date.t -> int * Date.day =3D 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. Rich. --=20 Richard Jones. http://www.annexia.org/ http://www.j-london.com/ >>> http://www.team-notepad.com/ - collaboration tools for teams <<< Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://winwinsales.co.uk/ - CRM consultancy ```
 Re: [Ocaml-lib-devel] Re: [Caml-list] ANNOUNCE: Library for handling Gregorian date calculations From: Julien Signoles - 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 = > > 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 ```