[Gambas-user] Different quantities of seconds from UNIX date...

Jussi Lahtinen jussi.lahtinen at gmail.com
Sun Apr 8 02:09:34 CEST 2018


Hmmm... no. Of course Val cannot read US format in Finland. And there isn't
another method to read it as local time.

*'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.'*

No, you can't, because Val fails when switching a language, which I just
recalled with my non working workaround.

My case is really simple. If I want alarm at "10.10.2018 12:00", I want it
to be written in file as "10.10.2018 12:00" and independently of where I
am, I should see the alarm, when my computer clock shows "10.10.2018
12:00". IE always assume local time.


Jussi



On Sun, Apr 8, 2018 at 2:48 AM, Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> 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/b81ab1e2/attachment-0001.html>


More information about the User mailing list