[Gambas-user] Date(Now) with time component under Ubuntu?
Benoît Minisini
g4mba5 at gmail.com
Tue Dec 4 12:56:04 CET 2018
Le 04/12/2018 à 11:23, Rolf-Werner Eilert a écrit :
> To give you an idea of the problem, here is a code snippet from this
> second application, it is in Form_Open:
>
> -----
> t$ = Date(Now)
> heute = String.Mid(t$, 4, 2) & "-" & String.Left(t$, 2) & "-" &
> String.Mid(t$, 7, 4)
> DerTag.Tag = Date(Now)
> DerTag.Text = "heute, " & Wochentag(Date(Now)) & ", " &
> Replace(heute, "-", ".")
> -----
>
>
>
> Today (4th December)
> - t$ becomes "12.03.2018 23:00:00"
> - 'heute' of course becomes "12-03-2018"
>
> Now it's curious:
> - DerTag.Tag becomes "04.12.2018 00:00:00" i. e. day and hour +1 !!
>
> And of course, it goes wrong here:
> - DerTag.Text becomes "heute, Dienstag, 03.12.2018"
>
>
> How to solve this mess???
>
> Regards
> Rolf
>
>
Read carefully the documentation about Date(), avoid implicit conversion
from Date to String, Read carefully the documentation about Print,
CStr() and Str(), and just don't mix local and universal date
representations.
For example, let's analyze the following expression:
t$ = Date(Now) ' Assuming that t$ is a String variable
Now -> Return a Date value corrresponding to the current date & time.
Date(Now) -> Return the date part, in the current localization (i.e. the
current timezone). It means that the time part is set to 00:00:00, but
in the current timezone.
t$ = Date(Now) -> Assign the previous date value to a string variable,
hence applying first the automatic conversion from Date to String. So it
actually means...
t$ = CStr(Date(Now))
CStr() converts the date into a UTC date representation, not in your
local representation. So you won't see a pure date: the time is shifted
according to your timezone.
For the other expressions, I can't tell you, you don't give any
information about the functions and variable you use.
And I guess it worked before because you used a Gambas version where you
had a bug in date / string conversion. I can't say more without you
giving more details.
Regards,
--
Benoît Minisini
More information about the User
mailing list