[Gambas-user] Best way converting dates into strings forth and back

Jussi Lahtinen jussi.lahtinen at gmail.com
Sat Dec 11 00:26:02 CET 2021


The second issue with other words.
You can pretend everything is in UTC already, for example instead of using
the keyword "Now", you write "CDate(CStr(Now))". And print every time with
CStr().
And example Date() and Format() functions you need to rewrite yourself,
because they use non-optional localization. Not sure if this would still
work. Such a deceivingly simple thing, but it's quite a mindfuck when going
into details.

This is mandatory, since everything is stored internally as UTC, and thus
the localization changes when timezone changes. And again, this means
"10.12.2021 22:27" is not the same in winter than in summer, unless the
"timezone" is UTC.

Jussi

On Sat, Dec 11, 2021 at 12:49 AM Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> Again, in different words. Here we give the date in local time and get the
> output in UTC:
>
> ? Cstr(Date(2021, 12, 10, 22, 27))
> 12/10/2021 20:27
>
> ? Cstr(Date(2021, 12, 10, 22, 27))
> 12/10/2021 19:27
>
> Depending if it is winter or summer. So, it doesn't work. The problem is
> in the loss of information. IE the relevant information is not stored.
>
> Does anyone else understand the issue?
>
>
> Jussi
>
>
> On Sat, Dec 11, 2021 at 12:06 AM Jussi Lahtinen <jussi.lahtinen at gmail.com>
> wrote:
>
>> Benoit, you misunderstand what I mean.
>>
>>
>>
>>> "12/10/2021 20:27 UTC" is different from "12/10/2021 19:27 UTC", so they
>>> are not the same date/time.
>>
>>
>> Of course, but they both are the result of converting the same *local*
>> date "10.12.2021 22:27" into UTC.
>>
>>
>>
>>> If you store the same date/time in an UTC string representation, you
>>> will have the same string, otherwise it is not the same date/time.
>>>
>>
>> Yes, Cstr(CDate("12/10/2021 22:27")) = "12/10/2021 22:27". I know this.
>> But it solves nothing, because still the second case applies.
>>
>>
>>
>>
>>> When you use the expression "the same date in UTC", you show that you
>>> are confusing dates with their string representation.
>>>
>>
>> Of course I meant the same date converted into UTC.
>>
>>
>> My full explanation of how dates work in Gambas is at:
>>> https://gambaswiki.org/wiki/doc/date
>>>
>>> I strongly suggest that you read it carefully.
>>>
>>
>> Done, many times. Two times again today. It does not say anything about
>> what I'm talking about.
>>
>>
>> Jussi
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211211/e9253794/attachment.htm>


More information about the User mailing list