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

Jussi Lahtinen jussi.lahtinen at gmail.com
Sat Dec 11 02:53:49 CET 2021


Challenge for anyone who thinks this is easy or that I merely don't
understand how it works.
Either use your own written calendar or the attached GAlarm (or go to the
software farm and download GAlarm). I challenge everyone to try to fix it,
or just test your own calendar in a virtual machine with timezone changes.

Set up:
Add some alarms with different dates, and put the same dates into a text
file for later comparison.

Four tests:
1. GAlarm (or your own program) running when time jumps forward (IE set the
date of the virtual machine so that it is just about to change timezone and
wait).
2. The program not running when time jumps forward.
3. The program running when time jumps backwards.
4. The program not running when time jumps backwards.

Goal:
None of these tests should influence the set dates. If the alarm is set up
to go off at 1.2.2023 12:00, it should do it 12:00, not 13:00, etc.

If you can make this work in all of those cases, you will get your name in
the GAlarm authors with special appraise. Also you will get this working
handy calendar for free. I'm not saying it is impossible, but surely such a
headache that I have given up on it for a moment. Way too frustrating.
Also, please do not report any success until you really have tested it. So
many times I have felt I got it and have fixed it...


Jussi

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

> 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/d0ca9c2a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GAlarm-0.6.7.tar.gz
Type: application/gzip
Size: 71298 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211211/d0ca9c2a/attachment-0001.gz>


More information about the User mailing list