[m-rev.] calendar module proposal

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jan 28 13:27:41 AEDT 2009


On Wed, 28 Jan 2009, Ian MacLarty wrote:

> On Tue, Jan 27, 2009 at 5:54 PM, Julien Fischer
> <juliensf at csse.unimelb.edu.au> wrote:
>>
>> On Tue, 27 Jan 2009, Ian MacLarty wrote:
>>
>>> On Tue, Jan 27, 2009 at 04:38:52PM +1100, Ralph Becket wrote:
>>>>
>>>> This looks good.
>>>>
>>>> Ian MacLarty, Tuesday, 27 January 2009:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Here's a proposal for a calendar module for the standard library.
>>>>> Could interested people take a look and give me some feedback?
>>>>> Since this module only implements the Gregorian calendar, it might not
>>>>> be suitable for working with dates prior to 1582.  Perhaps it should be
>>>>> renamed to gregorian_calendar or gcalendar?
>>>>>
>>>>> Ian.
>>>>>
>>>>> Index: library/calendar.m
>>>>> ===================================================================
>>>>> RCS file: library/calendar.m
>>>>> diff -N library/calendar.m
>>>>> --- /dev/null   1 Jan 1970 00:00:00 -0000
>>>>> +++ library/calendar.m  27 Jan 2009 03:51:25 -0000
>>>>> @@ -0,0 +1,961 @@
>>>>>
>>>>> +%-----------------------------------------------------------------------------%
>>>>> +% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
>>>>>
>>>>> +%-----------------------------------------------------------------------------%
>>>>> +% Copyright (C) 2009 The University of Melbourne.
>>>>> +% This file may only be copied under the terms of the GNU Library
>>>>> General
>>>>> +% Public License - see the file COPYING.LIB in the Mercury
>>>>> distribution.
>>>>>
>>>>> +%-----------------------------------------------------------------------------%
>>>>> +%
>>>>> +% File: calendar.m.
>>>>> +% Main authors: maclarty
>>>>> +% Stability: low.
>>>>> +%
>>>>> +% Proleptic Gregorian calendar utilities.
>>>>
>>>> Can prolepsy be cured with antibiotics?
>>>>
>>>
>>> No, but it might be cured by implementing a hybrid Julian/Gregorian
>>> calendar.  Such a calendar would use the Julian system before a given
>>> crossover date and the Gregorian system after this date.  The crossover
>>> date would need to be changable, because different countries started
>>> using the Gregorian calendar at different times.  This cure would have
>>> the side-effects of a more complicated interface and implementation.
>>
>> Premsuably the latter is exactly why that was what was done in the
>> Java API!  (See:
>> http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html>).
>>
>> Is it just matter of (optionally) allowing the crossover date to be set
>> when creating dates and durations?
>>
>
> No, I don't think so.  Firstly I don't think the crossover date is
> relevant for durations.  Secondly, you can't keep the crossover as
> part of the date value, because then you have problems with
> comparison.  If I have two dates with different crossover dates, but
> that represent the same point in time (for example 9-10-1977 with
> crossover 1-1-1500 and 9-10-1977 with crossover 1-1-1600) then how
> should these dates compare?  They can't compare as equal, because if I
> add a duration of negative 182500 days to each I'll get different
> results.  Intuitively though they should compare as equal because they
> represent the same point in time.
>
> To avoid this problem we could create a separate calendar value which
> we pass as an extra argument to the various calendar predicates.  The
> calendar value would represent either a full Julian calendar, a full
> Gregorian calendar, or a hybrid calendar with a crossover date.  Date
> values would then use some canonical internal representation so that
> the same points in time would compare as equal.

Ugh!  Here is my five cents:

- it should just be the proleptic gregorian calendar
- the module should just be called "calendar"

Julien.




>
> Ian.
> --------------------------------------------------------------------------
> mercury-reviews mailing list
> Post messages to:       mercury-reviews at csse.unimelb.edu.au
> Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
> Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
> --------------------------------------------------------------------------
>
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list