[Gambas-user] Different quantities of seconds from UNIX date...
Jussi Lahtinen
jussi.lahtinen at gmail.com
Sun Apr 8 01:48:26 CEST 2018
How do you include timezone to the string?
My current plan is to write the string assuming it's always in local time
and in Val compatible format:
Subst("&1/&2/&3 &4:&5:&6", Format(Month(hUserDate), "0#"),
Format(Day(hUserDate), "0#"), Year(hUserDate), Format(Hour(hUserDate),
"0#"), Format(Minute(hUserDate), "0#"), Format(Second(hUserDate), "0#"))
And then read it with Val.
Jussi
On Sun, Apr 8, 2018 at 1:51 AM, Benoît Minisini <g4mba5 at gmail.com> wrote:
> Le 08/04/2018 à 00:04, Jussi Lahtinen a écrit :
>
>> It's not simple. How do I save and load consistently time & date as
>> string given by user?
>>
>> If I use CDate and CStr, the problem occurs when the user gives time &
>> date before the "daylight saving" applies, because it will be hour off when
>> loaded after the "daylight saving" applies. IF the user is not in UTC time
>> zone. This is because UTC+1 <--> UTC yields different result than UTC+2
>> <--> UTC.
>>
>> If I use Val and Str, the problem occurs when language is changed.
>>
>>
>> Jussi
>>
>
>
> If you have a string that you know it is a date/time in local timezone
> (daylight saving is automatically added by the system to the local
> timezone, i.e. daylight saving "changes" the timezone), then you must use
> Val() to convert it to a Date type.
>
> And if you have to display a date to the user in its local timezone, you
> have to use Str() or Print or Format().
>
> If you use CDate(), then the string is assumed to be a date/time in UTC.
> And if you use CStr(), the date is displayed in UTC, using the american
> date format.
>
> You have to deal with timezone "by hand" only if you want to manipulate a
> string that represents a date that is not in UTC, and not in local
> timezone, daylight time saving included.
>
> If date strings were forced to always include the timezone, it would be
> clearer. But this is not the case, the timezone is implicit, and it's the
> kind of function you use that assumes it.
>
>
> Regards,
>
> --
> Benoît Minisini
>
> --------------------------------------------------
>
> This is the Gambas Mailing List:
> https://lists.gambas-basic.org/listinfo/user
>
> Search the list:
> https://lists.gambas-basic.org/cgi-bin/search.cgi
>
> Hosted by https://www.hostsharing.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20180408/41cf1986/attachment.html>
More information about the User
mailing list