Calendar Types
Bayley, Alistair
Alistair_Bayley at ldn.invesco.com
Mon Feb 14 06:10:08 EST 2005
> From: Ashley Yakeley [mailto:ashley at semantic.org]
>
> * Should we include a timezone field in CalendarTime?
Yes. If a CalendarTime doesn't carry timezone information with it, then the
user must bundle it. They will want to do this because (1) they will be
probably dealing with local time (2) a CalendarTime sans timezone is
equivalent to UTC, and is therefore not much use (i.e. we may as well use
UTC instead).
> * TimeZone represents a fixed offset to UTC. What should it look like
> internally, and what functions on it should we provide?
There are timezones which are not integral hour offsets, so an (hours,
minutes) pair, or maybe just ticks is sufficient. Or maybe a Duration (see
below). Ticks is probably best from an implementation point-of-view, right?
Should it include the timezone name? Although the name determines the
offset, a given offset could match many names, so to preserve information
we'd probably want to retain the timezone name internally. Do we want to
support timezone names?
Do we want to embed summer-time (daylight-savings) timezone behaviour into
the library? This would obviously be useful for displaying the correct local
time, but makes the timezone part of the library quite complex.
> OK, so here are the basic functions of System.Time.Calendar:
>
> utcToCalendar :: TimeZone -> UTCTime -> CalendarTime
>
> calendarToUTC :: TimeZone -> CalendarTime -> UTCTime
>
> CalendarTime should be a "struct", i.e. a datatype with its
> constructor and access functions exported.
I'm assuming System.Time.Calendar is Gregorian. How about
- a Duration type
- some calendar arithmetic functions
- arithmetic on Durations
e.g.
data Duration = Duration
{
-- this looks familiar...
durYear :: Int,
durMonth :: Int,
durDay :: Int,
durHour :: Int,
durMin :: Int,
durSec :: Int,
durPicosec :: Integer
} deriving ...
calendarAdd :: CalendarTime -> Duration -> CalendarTime
calendarDiff :: CalendarTime -> CalendarTime -> Duration
durationAdd :: Duration -> Duration -> Duration
durationDiff :: Duration -> Duration -> Duration
Alistair.
-----------------------------------------
*****************************************************************
Confidentiality Note: The information contained in this message, and any
attachments, may contain confidential and/or privileged material. It is
intended solely for the person(s) or entity to which it is addressed. Any
review, retransmission, dissemination, or taking of any action in
reliance upon this information by persons or entities other than the
intended recipient(s) is prohibited. If you received this in error, please
contact the sender and delete the material from any computer.
*****************************************************************
More information about the Libraries
mailing list