Kitz Forum

Announcements => Site & Forum Discussion => Topic started by: Weaver on December 25, 2018, 09:02:44 AM

Title: Time offset in profile
Post by: Weaver on December 25, 2018, 09:02:44 AM
I just noticed that the forum website was displaying a ‘current time is x’ value which was 1 hour less than the truth. I went into my profile and dug around, and saw it was explicitly set to -1 hour (auto). Perhaps this was something daft that I did some while ago given that all my machines work on permanent UTC / GMT, and I never go near BST summer time.
Title: Re: Time offset in profile
Post by: burakkucat on December 25, 2018, 02:27:58 PM
Perhaps this was something daft that I did some while ago given that all my machines work on permanent UTC / GMT, and I never go near BST summer time.

That is probably the correct reason. Like you, all my systems' RTCs are configured as GMT.  :)
Title: Re: Time offset in profile
Post by: Weaver on December 30, 2018, 07:45:15 AM
I seem to recall that there have been problems in the distant past because poor fools with IBM PCs in the 1980s had hardware clocks set to BST, with variations for summer time. This was presumably because no one, IBM/Microsoft being particularly guilty, specified the correct standard for setting the time value in the clock. I think I read somewhere about how Microsoft operating systems used to muck about with the hardware clock, poking adjusted values into it when the hour changes. This would of course all go wrong if the system was down or another o/s was in control over the point in time when the clock changed. I think I have remembered rightly, but apologies if not. But just over ten years ago, again, if memory serves, Microsoft had an attack of sanity and added support in Win NT family o/s for systems where the hardware clock was optionally always set to UTC, with no stupid changes being applied to it, and so no chance of the system time going wrong twice a year. I set my PCs up to have UTC hardware clocks and with NT set up accordingly.

Returning to topic [hallelujah] is the Kitz web server set to UTC/GMT ? Wondering what the offsets mentioned in the per-user profile settings are relative to?

If the webserver is using ‘relative to BST’ that could explain why my per-user-profile time was wrong, and it will go wrong again then this spring no? So I’ll need to adjust the offset twice a year.

If someone is in foreign-land / abroad-land, will their wall-clock local civil time be other that bst + constant? Because the times in the year when their summer time comes in are different, or they do not have summer time adjustment at all?

I’m just wondering if there is a library function easily available that will convert a UTC or Unix time value to an equivalent local wall clock value given an enumerated, named time zone.
Title: Re: Time offset in profile
Post by: kitz on December 30, 2018, 10:24:22 AM
Quote
Wondering what the offsets mentioned in the per-user profile settings are relative to?

afaik the webserver is UTC.  Not something I have specifically looked into but if I'm coding something for the site which needs a date I have to use one of the php functions to convert from Unix time. 

Quote
I’m just wondering if there is a library function easily available that will convert a UTC or Unix time value to an equivalent local wall clock value given an enumerated, named time zone.
The SMF forum software controls/converts the time according to your preferences set in Profile > Look and Layout > Time format.
Its the software that does all the converting.   According to the SMF manual quote "Local Time - Since a member may be from any part of the world, their local time is displayed."

Quote
So I’ll need to adjust the offset twice a year.

Shouldn't need to.  I never have had to as long as you leave settings to default.
See below for the default settings which should always display the correct time and automatically make any adjustments for BST etc.

Title: Re: Time offset in profile
Post by: kitz on December 30, 2018, 10:34:10 AM
ETA.   

In the main SMF administration panel, I have the default Server timezone set to London. 
Therefore by default the software will automatically convert UTC to the current clock time for London. 
If you've changed it to  -1 then the software will assume you are in a different time zone location.  You need to change it back to 0.
Title: Re: Time offset in profile
Post by: Weaver on December 30, 2018, 11:40:06 AM
I changed it to 0, so will that mean I am assumed to be on UTC, or BST in winter ?

I think I was being stupid originally, and reading the bit about an ‘offset’ I wondered ‘offset from what?’ and speculated that it might be an offset from my browser’s reported local time.

I do apologise sincerely for being thick: Since it is actually the server’s Unix time (UTC) + offset, then does that mean the server won’t do summer time ever, so offset=0 means I will see UTC? Or otherwise if it actually produces text output that is BST clock-on-the-wall local ‘time’, then will that show summer time when we’re in summer? But if so, how does it know to do that rather than UTC?

I thought different time zones would have different rules about summer time yes/no and start/end times, and then UTC is an always-zero-offset override instead of the per-territory zone BST which has offset 0 in winter. Does that make sense? I’m asking myself how much information the system would need to determine all the per-territory time zone locale. I’m assuming some systems have a database of time zones’ names and info so that apps don’t have to reinvent the wheel, and possibly database updates could be sent out, centrally managed, to allow change when territories change their policies or when new territories are added. I’ve seen UI with enumerated named time zone territories plus UTC as an override, one extra entry.

I’ve never had to handle this myself because everything I’ve ever written has been UTC-based. With one embarrassing exception. I once co-authored a comms program for a large financial organisation. They had a number of tiny pocket computers and sent messages from them to a server and back. One genius idea was adding a function whereby the time could be set correctly by an admin on one machine and then this correct time would get propagated as the machines talked to one another until after a while all would get the right time. All went well until unknown to me the company had one or two machines in the USA while most were in London. A US machine was set by someone to local time on the US east coast (EST). It then sent this value to a machine in London, which then, believing this value, set its own clock to be five hours out and then went around and poisoned all the other machines. Someone then corrected this madness so that the London machines then told the US ones and set them incorrectly too. Quickly realising this, in horror, I changed the code to use Unix time (UTC) everywhere, having stupidly picked the wrong library function, one that returned wall-clock local ‘time’ instead of the true time. Pushed out an update and problem solved. I had invented the world’s first chronovirus.
Title: Re: Time offset in profile
Post by: j0hn on December 30, 2018, 01:08:14 PM
The forum installation software is set to London.

If you changed the offset back to 0 it will automatically change the time for you so it is always correct.
Title: Re: Time offset in profile
Post by: burakkucat on December 30, 2018, 04:00:39 PM
I changed it to 0, so will that mean I am assumed to be on UTC, or BST in winter ?

No, not BST but GMT in winter.

UTC + time-zone offset 0 is GMT. The correct setting for this Nation that is relative to the height of the sun at the zero meridian.
Title: Re: Time offset in profile
Post by: kitz on December 30, 2018, 04:43:08 PM
J0hn and b*cat have already answered but to expand further.


Because I have explicitly set SMF to London/Europe as default, I would imagine that the forum software makes full use of the PHP DateTime extension (http://php.net/manual/en/timezones.php) which is explained quite nicely here (https://stackoverflow.com/questions/44631382/how-to-convert-unix-timestamp-correctly-to-bst-or-gmt-depending-on-the-date).