[Gambas-user] problem with the CDate function
Benoît Minisini
g4mba5 at gmail.com
Wed May 2 15:46:44 CEST 2018
Le 02/05/2018 à 15:38, Gianluigi a écrit :
>
>
> 2018-05-02 15:18 GMT+02:00 Mayost Sharon <sharon at 455.co.il
> <mailto:sharon at 455.co.il>>:
>
> Hello
>
> Operating system: Fedora 27 64 BIT
> Gambas 3.10.0
>
> I have a problem with the CDate function when I run the example that
> appears in this
> documentation:
>
> It takes me back one day
>
> I run:
>
>
> Print CDate ("09/06/1972 01:45:12")
>
> And it returns to me:
>
> 09/05/1972 22:45:12
>
>
> You must use Date and not CDate which locates the UTC date [0].
>
> Regards
> Gianluigi
> [0] https://en.wikipedia.org/wiki/Coordinated_Universal_Time
>
No, it's not the problem.
It's just that people must understand that CDate() interprets its
argument as an UTC date, and that Str() (hence Print) converts a date
into a local representation.
So if you use CDate(), you must use CStr() to go back to the original
string. Otherwise, use Val() and Str().
See the documentation about these functions. I think some non-american
examples should be added to make things clearer.
Regards,
--
Benoît Minisini
More information about the User
mailing list