<div dir="ltr"><div>This is how I do it, when I want to save & load the values as string, without being influenced by timezones.</div><div><br></div><div>Write as string:<br></div><div><br></div><div>sStringToBeSaved = Subst("&1/&2/&3 &4:&5:&6", Format(Month(hDateAndTimel), "0#"), Format(Day(hDateAndTimel), "0#"), Year(hDateAndTimel), Format(Hour(hDateAndTimel), "0#"), Format(Minute(hDateAndTime), "0#"), Format(Second(hDateAndTimel), "0#"))</div><div><br></div><div><br></div><div>Read as date:</div><div><br></div><div>Dim sStr, sDate, sTime As String[]<br></div><div><br></div><div> sStr = Split(sLoadedString, " ")<br> <br> sDate = Split(sStr[0], "/")<br> sTime = Split(sStr[1], ":")<br> <br> hDateAndTime = Date(sDate[2], sDate[0], sDate[1], sTime[0], sTime[1], sTime[2])<br></div><div><br></div><div><br></div><div></div><div><br></div><div>Jussi<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 7, 2018 at 9:34 PM, ML <span dir="ltr"><<a href="mailto:d4t4full@gmail.com" target="_blank">d4t4full@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"><div><div class="h5">
On 07/06/18 15:11, Gianluigi wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">2018-06-07 17:12 GMT+02:00 Benoît
Minisini <span dir="ltr"><<a href="mailto:g4mba5@gmail.com" target="_blank">g4mba5@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le 07/06/2018 à 16:51,
Gianluigi a écrit :<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I wrote it even if I imagined it was wrong (it works
here), I'm sorry.<br>
It's useless, with the dates I still do not understand
anything.<br>
These coming days, I will try to write a my wiki to and
submit it to your judgment.<br>
Regards<br>
Gianluigi<br>
<br>
</blockquote>
<br>
I try to explain again:<br>
1) Date & times are internally represented in UTC
date. See them as a number of days since an absolute
instant in the past. You can get this number with
CFloat(AnyDate). The integer part is the number of days,
the fractional part is the part of the day (the precision
is the millisecond).<br>
2) Each time you read or you write a date & time as a
string, you *must* know the timezone associated with the
string representation. *But* this timezone is implicit, as
it is not written inside the string representation
(something that I should add to Gambas).<br>
In other words, "2018/6/7" *cannot* represent an absolute
time instant. It depends on the implicit timezone.<br>
3) So, all Gambas functions that deal with date & time
as a string *must* assume a timezone. Some functions
assume UTC timezone, and others assume local timezone.
Normally, all documentation pages on the wiki says which
one is used.<br>
Is it clearer now?<span class="m_-7361643457249254760gmail-HOEnZb"><font color="#888888"><br>
-- <br>
Benoît Minisini<br>
<br>
</font></span></blockquote>
<div><br>
</div>
<div>Hi Benoit,<br>
sorry for the delay, I had to go out.<br>
The difference between local and UTC is clear to me.<br>
I find it difficult to memorize, to fix well in my mind,
to fully understand the translation into the string.<br>
Suppose we have a CUsers class where I store user data
including the date of birth.<br>
Suppose I use this class as an array:<br>
hObj = New CUsers (iId, sName, sSurName, dDate, ...)<br>
$hGlobalObject.Add(hObj)<br>
If I have to save the date in an ini file like Settings
and I want to be sure that I do not have problems, how do
I translate the date to be saved into a string, and then
how can I re-translate it into a date format from ini?<br>
So I'm in confusion, I would use CStr and then CDate to
stay in UTC and then display the dates with Format.<br>
I know I'm an idiot, and I'll continue to use a
database...<br>
Regards<br>
Gianluigi<br>
</div>
</div>
</div>
</div>
</blockquote>
<br></div></div>
I'd break the date down to day, month, year, and store them as 3
separate data units.<br>
Then, when retrieving, read the three separate data items and use:<br>
<br>
Dim userBirthday As Date = Date(savedYear, savedMonth, savedDay)<br>
<br>
So userBirthday will be a Date with the proper value... If I
inderstood it correctly, that is!<br>
</div>
<br><br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
<br></blockquote></div><br></div>