Time library design proposal

Keean Schupke k.schupke at imperial.ac.uk
Wed Feb 2 10:09:49 EST 2005


>
>
>
>  getDateGregorian :: JulianDay -> CalendarDate
>
>  -- much less useful, but easy to write
>  getDateJulian :: JulianDay -> CalendarDate
>
>I can see a number of applications for calendar dates by themselves and 
>perhaps times of day also. This also might be more 
>internationalisation-friendly, as users can create their own calendar 
>types and still use TimeOfDay.
>
>On the other hand, it adds two levels of construction to CalendarTime.
>
>  
>

Don't forget decimal time (100 seconds = 1 minute, 100 minutes = 1 hour, 
10 hours = 1 day)...

I still feel using a simple single unit counter (picoseconds?) and then 
defining a class allowing different
representations is the most flexible way to do this... Ignoring the 
TAI/UTC issue, this would be how
I would define the interface:

type TAI = Word128
getTAI :: IO TAI -- or Integer or Word64?

class Calendar c where
    fromTAI :: TAI -> c
    toTAI :: c -> TAI

data Gregorian = Gregorian {
    second :: Int,
    minute :: Int,
    hour :: Int,
    dayOfMonth :: Int,
    dayOfWeek :: Int,
    weekOfYear :: Int,
    monthOfYear :: Int,
    Year :: Int } -- enumerations may make more sense for 
dayOfWeek/monthOfYear



This allows users to implement alternative arrangements and convert to 
and from TAI.

    Keean.




More information about the Libraries mailing list