[Gambas-user] bug in function cstr()?
taboege at gmail.com
Sun Sep 13 13:21:26 CEST 2020
On Sun, 13 Sep 2020, Angel wrote:
> in the cstr () function with dates it gives me the following results:
> Print now 13/09/2020 12:36:21
> Print str(now) 13/09/2020 12:36:38
> Print cstr(now) _09/13/2020 10:36:30.929_
> Print date 13/09/2020 00:00:00
> Print str(date) 13/09/2020 00:00:00
> Print cstr(date) _09/12/2020 22:00:00_
> my time zone: Time zone: Europe/Madrid (CEST, +0200)
> my vesion of gambas: 3.15.1
It's not a bug. When you Print a value, it is internally converted to
a string using Str() semantics, so `Print x` and `Print Str(x)` should
always give you the same result.
The (documented!) difference between Str and CStr is that Str uses
localization information, like your timezone, and CStr doesn't.
Gambas stores dates internally in UTC, so when you
you get the `Now` in UTC, which reads the same as two hours in the past
for you in Madrid. But when you `Print Str(Now)`, the Date is treated
as if it were relative to your current timezone instead of UTC, so you
get the same information printed that your wallclock shows you.
Also notice that the date format changes -- this is due to another part
of your localization. Str picks it up, CStr doesn't.
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User