[Gambas-user] Format function changes date value
Benoît Minisini
g4mba5 at gmail.com
Thu Jun 7 14:42:32 CEST 2018
Le 07/06/2018 à 11:55, George a écrit :
> It's not a lack of understanding on my part. I have developed software
> that must work across different time zones, and it certainly adds a
> layer of complication to things, since time data must be dealt with
> based on location, and display of times must take into account the
> user's location (showing everything as GMT is the lazy way out, as it
> puts the burden of time conversion on the user.)
>
> However, in this particular case I'm working with data that's in a
> single location, and only deals with days, not times. That should be
> easy, since it shouldn't need to deal with time zones. And yet, due to
> the way date functions work, what should be a simple calculation, such
> as how many days are between 1-Jun-2018 and 3-Jun-2018, needs to know
> the GMT offset of the machine it's running on, and fudge the date into a
> date/time value in order to get the correct result. (Just changing
> CDate() to Date(), as previously suggested, did not work for me.) Yes,
> that can be done, but because of what that would have entailed, in this
> case I decided that porting the app to a different language was the
> better option for me.
You get the difference between two dates with DateDiff(). Where did you
see that you had to deal with timezones?
>
> IMHO all date functions should work internally as based on GMT or local
> time, not a mix of both.
All date & times are internally stored in UTC.
But all date & times functions that deal with date & time string printed
representation (Str & Val & Format) have to supposed a local date,
because none of them have an optional argument that would tell the timezone.
Date & times functions using a non-printed string representation (CStr &
CDate) assume an UTC timezone.
--
Benoît Minisini
More information about the User
mailing list