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

Jussi Lahtinen jussi.lahtinen at gmail.com
Tue Dec 14 02:34:18 CET 2021


> But wouldn't it be easy enough to introduce two different ways of
> processing timecodes, such as there are for ordinary strings and UTF
> strings?
>
> Classic functions -> ordinary strings
> String.Class -> UTF strings
>
> Classic functions -> always UTC encoding
> Localtime.Class -> Local Date & Time
>
> Or (to enable saving in and restoring from strings) the possibility to
> add "UTC" for UTC time, or one of the timezone codes (like CEST) for
> local time.
>

I think the simplest way would be to just disable all the conversions.
When I give date with Date() function, it should not convert and store it
as UTC, but let it be just as it is.
Then the user could simply just use it as the local time or when needed,
they could convert it by themselves.
Easy and intuitive. And no need for extra functions.



> By the way, how is it done in Java, Python... Maybe we can learn from them.
>

C doesn't offer much, you need to do things by yourself. Python I don't
know. In Java it is an absolutely horrible mess. For example, there exists
month number 13, January is month number 0 and so on. I guess they have got
some sense to it lately, not sure. I have enjoyed the privilege of not
having to find it out.
Maybe someone could tell us about the case of Python... I haven't used it
much.

Anyway, we need to convince Benoit that this needs improvement.


Jussi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211214/4a1d6b16/attachment.htm>


More information about the User mailing list