Time library design proposal
Ashley Yakeley
ashley at semantic.org
Wed Feb 2 07:56:36 EST 2005
In article <Pine.WNT.4.61.0502012323540.2748 at philo>,
"S. Alexander Jacobson" <alex at alexjacobson.com> wrote:
> Are you seriously saying that you never have use
> for a Date without a Time? On what date were you
> born?
There's something to be said for representing date and time of day
separately in calendar time, something like this:
data CalendarDate = CalendarDate
{
cdYear :: Int,
cdMonth :: Int,
cdDay :: Int
}
data TimeOfDay = TimeOfDay
{
todHour :: Int,
todMin :: Int,
todSec :: Int,
todPicosec :: Integer -- or nanosec
}
data CalendarTime = CalendarTime
{
ctDate :: CalendarDate,
ctTime :: TimeOfDay
}
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.
--
Ashley Yakeley, Seattle WA
More information about the Libraries
mailing list