www.ClassicTW.com
https://mail.black-squirrel.com/

RFC Changing the time of an update to ignore timezones.
https://mail.black-squirrel.com/viewtopic.php?f=15&t=25296
Page 1 of 1

Author:  Maniac [ Fri Dec 18, 2009 8:17 am ]
Post subject:  RFC Changing the time of an update to ignore timezones.

Currently the sector/Port fields Updated are set to the users local time which will cause problems if we decide to sync databases.

I am going to throw out a couple of ideas and want some feedback as I don't want to just change things willy-nilly


There are 2 real options I see

Using the server time.
If you use CT you get a date that is 12 years off.
i.e 06:57:47 AM Sat Dec 18, 2021 as opposed to Today Fri Dec 18, 2009.

Using Zulu time. (for the non military perps here, also known as GMT or UTC)
It is Universal it doesn't have the steenking problem of Daylight Saving Time 2 or more times a year.
It is easy to use; there are built in functions to use it in Delphi/Windows/Linux/Mac OS.

The only Con I see to using it is the extra difficulty and it will break backward compatibility as older databases will still
save in local time.


Comments, flames are welcome but please redirect smack to the appropriate forum.

Author:  NjoY [ Fri Dec 18, 2009 1:02 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

There must be a good reason for you not being able to subtract 12 years from T. So i vote for GMT. (i'm in it too, so easier dns me. heh)
But does it really matter if we are ALL 21 years in front?

Author:  the reverend [ Fri Dec 18, 2009 3:28 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

the right way is to use UTC time (GMT/ZULU).

Author:  Singularity [ Fri Dec 18, 2009 3:53 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

The correct way is UTC. It's the universal standard for coordinating time zones, why break that when
someone might need to coordinate across helpers as well?

We can still remain compatible with local and server times by calculating the offset. Since the local
offset will be required for doing the UTC work, you might want to store it as a variable just in case
someone needs it. Might also want to store the current UTC time as part of the time command too.

For local server time we'll just keep doing it the way we've been doing it, check ct, calculate results.
It's actually not exactly 12 years, there's both a day and a timezone difference too.

Author:  Maniac [ Fri Dec 18, 2009 5:30 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

the right way is to use UTC time (GMT/ZULU).

From the discussion it looks like UTC wins so UTC it is.

And to add to this discussion I was wrong about the built in Delphi function....
I had to roll my own
Thankfully there was the TTimeZoneInformation record and GetTimeZoneInformation function

So at present I'm not changing anything in the database I am just calculating Zulu time.

Here is the actual function(s) I'm using can someone point out if there is anything obviously wrong?
function ConvertToUTC(val : TDateTime) : TDateTime;
begin
// Will Incrementing the Hour work correctly East of GMT
Result:=DateUtils.IncHour(val,GetTimeZoneBias);
end;
function GetTimeZoneBias : integer;
var
TimeZone : TTimeZoneInformation;
begin
GetTimeZoneInformation(TimeZone);
Result := TimeZone.Bias div 60;
end;

Author:  Singularity [ Fri Dec 18, 2009 6:10 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

How is the TimeZone calculated, from the main clock?

Is .bias in minutes? If so, does it ever return partial hours?

Author:  Maniac [ Fri Dec 18, 2009 7:59 pm ]
Post subject:  Re: RFC Changing the time of an update to ignore timezones.

AFAICT

GetTimeZoneInformation is a windows function in Kernel32

The Docs say that bias is in minutes and the formula for UTC is
UTC = local time + bias

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/