[Gambas-user] gb3: date/time reporting odd fractional value
Benoît Minisini
gambas at ...1...
Thu Jun 23 13:33:04 CEST 2011
> On 06/23/2011 02:46 AM, Benoît Minisini wrote:
> >> According to some previous answers to my questions about performing
> >> arithmetic operations on dates and times, the fractional part of a date
> >> (cfloat[now] - fix[cfloat(now)]) represents the time of day and the
> >> integer part (fix[cfloat(now)]) represents the number of days elapsed
> >> since the beginning of time.
> >>
> >> So if it's 12:00 PM then cfloat(now) should display x.5, meaning half
> >> the day has passed.
> >>
> >> If I enter ?cfloat(now) in the immediate window I get something like
> >> 2487839.71017654 even though it's 10:02 PM. If x.0 is midnight, x.5 is
> >> noon, etc., how is x.7 10:00 PM? Shouldn't 10:00 PM be something closer
> >> to x.916666674?
> >>
> >> I thought at first it was because I was scaling time, but the immediate
> >> window proved that wrong (immediately!). Any insight appreciated as
> >> always.
> >
> > Date/time values are internally stored in GMT time.
>
> I'm reading about GMT on Wikipedia now... How would one interpret the
> returned values with respect to GMT?
Sorry, we should not say "GMT" anymore, but "UTC" instead.
For example, in France, the time zone is "-1". It means that dates in France
are one hour earlier than in UK (which has a time zone of "0", i.e. the UTC is
used).
As Gambas must internally store dates independently of the location, it uses
UTC.
So, in France, Gambas stores dates one hour later, and does the contrary when
printing them.
In other words, if you send "23/06/2011 10:00:00" from a Gambas program
running on a french computer to a Gambas program running on an english
computer, it will receive "23/06/2011 11:00:00". But, internally, it will be
the same date.
Regards,
--
Benoît Minisini
More information about the User
mailing list