[Gambas-user] Possible CDATE issue Latest version

Brian G brian at westwoodsvcs.com
Sat Nov 19 21:38:57 CET 2022


I am not trying to cause change, I understand it's the way it is. 
I am just expressing my own confusion... 

Maybe just a bit thick then..... 

"Failure is the key to success; 
each mistake teaches us something" .. Morihei Ueshiba 
Brian G 

----- On Nov 19, 2022, at 11:54 AM, Jussi Lahtinen <jussi.lahtinen at gmail.com> wrote: 

> Tobias, don't you think that this would be easier if the dates would mimic the
> behavior of a paper calendar?
> To me this is so obvious, it's old, proven tech and immune to timezone issues
> (and GNU Lib C supports it). Maybe I'm missing something?
> Of course, it is too late to modify the existing behavior, because of backward
> compatibility, but am I really the only one who thinks that would be a useful
> feature?

> Jussi

> On Sat, Nov 19, 2022 at 8:48 PM Tobias Boege via User < [
> mailto:user at lists.gambas-basic.org | user at lists.gambas-basic.org ] > wrote:

>> On Sat, 19 Nov 2022, Brian G wrote:
>>> ----- On Nov 19, 2022, at 9:43 AM, Benoit Minisini [
>>> mailto:benoit.minisini at gambas-basic.org | benoit.minisini at gambas-basic.org ]
>> > wrote:

>> > > Le 19/11/2022 à 17:26, Brian G a écrit :

>> > >> ----- On Nov 19, 2022, at 2:43 AM, Benoit Minisini
>>> >> [ mailto:benoit.minisini at gambas-basic.org | benoit.minisini at gambas-basic.org ]
>> > >> wrote:

>> > >>> Le 18/11/2022 à 20:36, Brian G a écrit :
>> > >>>> With the latest version of gambas, I am getting the strangest issue, I
>> > >>>> dont understand, not sure if its a bug
>> > >>>> cdate returns different values if called with a class public variable.
>> > >>>> Locks like possibly like in the last case
>> > >>>> its return the gmt time.

>> > >>>> Hello world 11/18/2022 11:30:56
>> > >>>> CDATE(now) 11/18/2022 11:30:56
>> > >>>> Eval("cdate(now)") 11/18/2022 11:30:56
>> > >>>> dim thedate as string = "CDate(now)"
>> > >>>> Try ddate = Eval(thedate) 11/18/2022 19:30:56.895


>> > >>> The printed strings are normal. What did you expect?

>> > >>> --
>> > >>> Benoît Minisini.


>>> >>> ----[ [ http://gambaswiki.org/wiki/doc/netiquette |
>> > >>> http://gambaswiki.org/wiki/doc/netiquette ] ]----

>> > >> I expect the times to all be the same, the last time printed is a different time
>> > >> zone
>> > >> although the same expression is being evaluated.


>> > > It can't be the same as in your script, 'ddate' is a string that
>> > > receives the result of evaluating an expression that returns a date.

>> > > Hence this date is converted to a string automatically with CDate() to
>> > > be put inside the 'ddate' variable, and so you get the UTC
>> > > representation of the date as returned by CDate().

>> > > Regards,

>> > > --
>> > > Benoît Minisini.


>>> > ----[ [ http://gambaswiki.org/wiki/doc/netiquette |
>> > > http://gambaswiki.org/wiki/doc/netiquette ] ]----
>> > Maybe I am just a bit thick but I had expected

>> > print cdate(now)

>> > and

>> > dim a as string = cdate(now)
>> > print a

>> > To produce the same output value!

>> > This is what is produced

>> > 11/19/2022 10:19:18
>> > 11/19/2022 18:19:18.16


>> No! The Print instruction converts dates to strings for humans, i.e.,
>> using the current locale, including timezone. By contrast, assigning
>> to a string variable uses the low-level conversion function CStr()
>> which does not use the current locale.

>> You should expect

>> Dim a As String = CDate(Now)
>> Print a

>> and

>> Print CStr(Now)

>> to produce the same output, as well as

>> Dim a As String = Str$(Now)
>> Print a

>> and

>> Print Now

>> And indeed, they do. The Print documentation tells you that.

>> Best,
>> Tobias

>> --
>> "There's an old saying: Don't change anything... ever!" -- Mr. Monk

>> ----[ [ http://gambaswiki.org/wiki/doc/netiquette |
>> http://gambaswiki.org/wiki/doc/netiquette ] ]----

> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20221119/1b0ed5a8/attachment-0001.htm>


More information about the User mailing list