[Gambas-user] Daylight "saving" and time zones

Bruce adamnt42 at gmail.com
Mon Oct 28 04:55:08 CET 2019


Jussi,
Consider the problem we had with auction times as in the attached picture.

Our solution was :
1) Decide on the timezone for the unique instant. In our case it was the 
time/timezone on the DB server.
2) On the way in, i.e. writing an "event time" to the shared database
a) decide the timezone that the source date is in.
b) convert it to the server timezone
3) On the way out, i.e. whenever a user PC accesses the event, convert 
it to their local timezone.
We wrote our own methods to convert the times to (and from) a local PC 
timezone (This was not easy!)
So,
Writing:
Source (string) --> Event time with TZ --> Event time in server TZ
Reading
Event time in server TZ --> Event time in local PC TZ --> format it

So consider your problem in the same way, as if you had more than one 
machine in more than one TZ.

hth
Bruce


On 28/10/19 1:05 pm, Jussi Lahtinen wrote:
> 
>     How do you write your date/time to the disk?
> 
>     If you use the READ/WRITE instructions, the date/time will be always
>     read and written by Gambas in binary form, i.e. in UTC date/time.
> 
>     Otherwise, if you do that by yourself, you have to store the timezone
>     with it manually.
> 
> 
> This is how I load the alarms:
> 
>        sTotal = Settings[sPath &/ "Date&Time", ""]
> 
>        sStr = Split(sTotal, " ")
> 
>        sDate = Split(sStr[0], "/")
>        sTime = Split(sStr[1], ":")
> 
>        hAlarm.hTotal = Date(sDate[2], sDate[0], sDate[1], sTime[0], 
> sTime[1], sTime[2])
> 
> This is how I save the alarms:
> 
> Settings[sPath &/ "Date&Time"] = Subst("&1/&2/&3 &4:&5:&6", 
> Format(Month(hAlarm.hTotal), "0#"), Format(Day(hAlarm.hTotal), "0#"), 
> Year(hAlarm.hTotal), Format(Hour(hAlarm.hTotal), "0#"), 
> Format(Minute(hAlarm.hTotal), "0#"), Format(Second(hAlarm.hTotal), "0#"))
> 
> IE, save and loaded as local time.
> 
> IE, if there is this on the disk:
> Date&Time="10/28/2019 08:30:00"
> 
> It will be loaded 08:30 as local time and internally 06:30. But if time 
> zone changes, then it is suddenly 07:30 local time and internally 06:30.
> 
> Saving the values as UTC doesn't fix that as there is no control on how 
> it is interpreted/converted to local time.
> 
> Did you read the example I gave that applies within Finland?
> 
> 
> Jussi
> 
> 
> 
> 
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Australia-Timezones-Daylight.png
Type: image/png
Size: 65927 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20191028/1c10665e/attachment-0001.png>


More information about the User mailing list