[Gambas-user] Daylight "saving" and time zones

Tobias Boege taboege at gmail.com
Mon Oct 28 01:36:51 CET 2019

On Sun, 27 Oct 2019, Benoît Minisini wrote:
> Le 27/10/2019 à 22:19, Jussi Lahtinen a écrit :
> > 
> >     This is what I want in essense:
> > 
> >     ? date(2019,10,27,2,3, "UTC")
> >     10/27/2019 02:03:00
> > 
> >     ? cstr(date(2019,10,27,2,3, "UTC"))
> >     10/27/2019 02:03:00
> > 
> >     In other words, if I write date 27.10.2019 and time 2:03, it should
> >     be just that and nothing else. I don't want to make guesses where
> >     the user might travel or when there might be other sudden changes in
> >     the time zone. System.timezone is not useful here, because it is not
> >     constant.
> > 
> You are plain wrong. A date is not a duration, it's an instant. Without a
> time zone, it means nothing.

FWIW, Perl 6 (now named Raku) follows the same model and even the same
terminology, almost. I for one like to think that the designers of that
language spent a lot of time on getting many things right and they had
a big amount of experience with everyday programming to consult. There,
DateTime represents a usable date + time in a timezone [1]. You have
methods to travel between timezones. An Instant is a point in time without
a timezone attached [2], for local time, like "the instant the process
was started". Duration is the difference of two DateTimes or Instants
and does not have a timezone [3].

I think in Gambas one problem is that timezone in a Date is implicit,
it's not an inspectable property, which is of course due to Date being
a small native datatype. That's why you have to remember the rules for
Date manipulation mentioned earlier in this thread, about which functions
interpret Dates in which ways.

Jussi: I would say that if you need "13:00" to mean "13:00 in whatever
timezone my computer happens to be when I check", you should store it
as a string and always reinterpret it in your local time when needed.

And from a purely pragmatic point of view: for appointments I rely on the
well-established iCalendar format, which supports the floating local time
and specific timezones alike [4].


[1] https://docs.perl6.org/type/DateTime
[2] https://docs.perl6.org/type/Instant
[3] https://docs.perl6.org/type/Duration
[4] https://tools.ietf.org/html/rfc5545, section 3.3.5

"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list