Jonathan M Davis wrote:
On Friday, October 08, 2010 14:58:35 Walter Bright wrote:
It bothers me that there are so many types, i.e. "various duration
types", "various interval types", etc.
Now that I read that again, why is there both a "duration" and an
"interval"?
A duration is a length of time with units while an interval is two time points
(or a time point and a duration) which therefore designate a duration which is
fixed in time.
Ok, makes sense.
So, they are distinct (the concepts are from Boost). There are
multiple duration types primarily because you can't convert between months and
small units without a specific date, so you can't convert something like 5 months
to days without knowing which months you're dealing with.
True, but why would a month be a type other than int?
However, I have
definite worked on making it so that you don't have to worry about the multiple
duration types in most cases. You'd do something like Dur.years(5) + Dur.days(2)
to create a duration of 5 years and 2 days, and you don't have to know or care
what the duration types are.
Ok, but I don't see that requires more than one duration type.
There are multiple interval types only to deal with infinity. You have Interval,
with a definite begin and end, PosInfInterval which goes from a specific time
point to infinity, and NegInfInterval which goes from negative infinity to a
specific time point. The infinite intervals are primarily of interest in creating
infinite ranges. A lot of user code could simpler ignore them.
Ok.
Why are there multiple "various time zone classes" instead of "a" time
zone class?
There are multiple time zone classes because it uses polymorphism to deal with
the rules for a given time zone. The really basic LocalTime and UTC deal with
most cases, but for anyone who really needs to deal with multiple time zones,
PosixTimeZone and WindowsTimeZone will be invaluable (I'd love to only have one
of those, but Windows just doesn't deal with time zones like the Posix world
does).
I agree some kind of polymorphism for time zones is necessary. [rant]
Timezones should be an operating system service, if for no other reason
than it sucks to have all your apps break when some tinhorn country
decides to change their daylight savings time, etc.[/rant]
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos