About time zones... - Page 1
Forum section: electronics / general

author: VinzC
author_rank: Frequent Contributor
timestamp: July 16, 2017, 01:37:14 pm
content: I've just watched Dave's EEVBlog2(World Time Zones explained).If that sounds interesting, developers should never attempt at writing code for managing time zones though. You'll find why in an excellent video made by(Tom Scott, Computerphile).

author: tggzzz
author_rank: Super Contributor
timestamp: July 16, 2017, 02:34:17 pm
content: Anything to do with time and dates is more difficult than you imagined. And that includes recursion.Let's start withsimplequestions:how many milliseconds are there in a second?how many seconds are there in a minute?how many minutes are there in an hour?how many hours are there in a day?how many days are there in a month?how many months are there in a year?how many years are there in a century?

author: VinzC
author_rank: Frequent Contributor
timestamp: July 16, 2017, 09:17:27 pm
content: Quote from: tggzzz on July 16, 2017, 02:34:17 pmWell, the answer is simple. It just depends on where you are and when you ask the question.

author: tggzzz
author_rank: Super Contributor
timestamp: July 16, 2017, 09:46:07 pm
content: Quote from: VinzC on July 16, 2017, 09:17:27 pmAssume here and now. What's your answer?

author: VinzC
author_rank: Frequent Contributor
timestamp: July 16, 2017, 09:57:44 pm
content: Quote from: tggzzz on July 16, 2017, 09:46:07 pmDefine "here" and "now"? Is it your "here" or mine? Is it the "now" you typed the question or the "now" I'll post the reply? Shall I account for the propagation delay and the case my reply takes more than 4 months (and I switch to winter time). Hmmm... I need a couple of weeks to reply ;-) .

author: tggzzz
author_rank: Super Contributor
timestamp: July 16, 2017, 10:00:12 pm
content: Quote from: VinzC on July 16, 2017, 09:57:44 pmAll valid, but none of that changes the answers

author: alm
author_rank: Super Contributor
timestamp: July 17, 2017, 02:47:07 pm
content: Quote from: tggzzz on July 16, 2017, 10:00:12 pmOf course it does. Some places observe daylight savings, others do not.Quote from: tggzzz on July 16, 2017, 02:34:17 pmAssuming we are talking UTC (so no daylight savings or politicians changing timezones):1000 milliseconds in a second59, 60 or 61 seconds in a minute (leap seconds)60 minutes in an hour24 hours in a day (may be 23 or 25 if daylight saving is observed)between 27 and 31 days in a month.12 month in a year*100 years in a centuryWhat pitfalls did I miss (step into)?*) assuming Gregorian year. A year as part of an ISO 8601 week date may last until January of the next Gregorian year and may have 13 or maybe even 14 (partial) months.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 17, 2017, 03:02:12 pm
content: I would recommend against using UTC, the length of the day varies considerably during the year due to the earth's rotation varying.I would advisehttps://en.wikipedia.org/wiki/Barycentric_Dynamical_TimePS1000 milliseconds in a secondNothing wrong with that statement... in fact it is the definition of a milli. 1000 milliaardvarks in an aardvark

author: tggzzz
author_rank: Super Contributor
timestamp: July 17, 2017, 04:13:11 pm
content: Quote from: alm on July 17, 2017, 02:47:07 pmIn the UK, 1752 had 10 fewer days. I've heard tales that the tax year boundary used to be the equinox, and rather than change the amount of tax gathered, they kept the tax year the same length. Currently the tax year boundary is April 5th/6th.Practically youhaveto include DST; hence 23/24/25 is correct.Different definitions of days and lunar months, of various types - but they aren't part of the calendar.QuoteHow narrow minded and parochial; a common fallacious assumptionOne calendar has up to 19 months of 19 days - plus a 4 or 5 days that aren't in months.

author: tggzzz
author_rank: Super Contributor
timestamp: July 17, 2017, 04:17:32 pm
content: Quote from: NivagSwerdna on July 17, 2017, 03:02:12 pmSometimes UTC is precisely the most appropriate definition of time; it all depends on how you areusingtime.QuoteNot quite as simple as that. Leap seconds are added/subtracted at convenient instants, not when a definition of time has shifted by 1000ms.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 17, 2017, 06:06:48 pm
content: Quote from: tggzzz on July 17, 2017, 04:17:32 pmSeconds are always 1000 milli-seconds long by definition. Indeed Seconds are well defined too... 9192631770 periods.... Cs133.... etc.Leap seconds are a human thing to keep their time in sync with the rotation of the planet they are on. Indeed the extra seconds are added where convenient in order to keep UT1 and UTC reasonably close together (DUT1). When an extra second is added... it is always the same size as the others and its likewise 1000 as big as 1/1000th of a second.I'm not saying your seconds appear to be as long as mine.... since it's all relative. (and depends on our velocity/gravitational effects etc).

author: Zero999
author_rank: Super Contributor
timestamp: July 17, 2017, 06:15:36 pm
content: Quote from: NivagSwerdna on July 17, 2017, 06:06:48 pmIt's pretty daft measuring time, to any degree of accuracy, in anything but seconds or milliseconds. The calender can easily be modified by using satellites to measure the earth's position, relative to the moon and the sun.

author: tggzzz
author_rank: Super Contributor
timestamp: July 17, 2017, 08:01:18 pm
content: Quote from: NivagSwerdna on July 17, 2017, 06:06:48 pmYou appear to be confusing durations with calendars. They are fundamentally different and incompatible, despite their usingsimilarunits. And therein lies a lot of the complexity

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 17, 2017, 09:31:23 pm
content: Quote from: tggzzz on July 17, 2017, 08:01:18 pmHm... well I'm certainly not disputing that calendars are confusing... they involve popes and emperors. But they are defined by epoch and duration thereafter so I think they are most certainly related.

author: tggzzz
author_rank: Super Contributor
timestamp: July 17, 2017, 10:08:44 pm
content: Quote from: NivagSwerdna on July 17, 2017, 09:31:23 pmSimple example... A one second duration (number of times an ion has waggled its tail) can finish an >hour later than it started, e.g. 00:01:59.5 to 03:00:00.5 Or, of course, finish before it started.

author: hamster_nz
author_rank: Super Contributor
timestamp: July 18, 2017, 04:44:06 am
content: Quote from: tggzzz on July 17, 2017, 04:13:11 pmWhich brings me to my favorite time zone - Troll time (yes, I kid you not - look in /usr/share/zoneinfo/Antartica) - it has +1 and +2 hour Daylight Saving, so you can have two short days and two long days in a year.

author: hamster_nz
author_rank: Super Contributor
timestamp: July 18, 2017, 04:54:51 am
content: Quote from: NivagSwerdna on July 17, 2017, 03:02:12 pmWell there goes a few more hours on Wikipedia and in the more obscure corners of the Interweb....

author: alm
author_rank: Super Contributor
timestamp: July 18, 2017, 05:00:30 am
content: Quote from: tggzzz on July 17, 2017, 04:13:11 pmWhy? Look atthis map. If you are in any of the light or dark gray countries, then you would not observe daylight saving, and hence a day would be 24 hours (unless politicians mess with the daylight savings, which is incidentally why I picked UTC which does not observe daylight savings either). You refused to specify location, so to me that means the person answering the question can assume any location they wish (I imagine implied that it should be on earth). So North Korea, which does not observe daylight savings, would be a valid pick.

author: Jeroen3
author_rank: Super Contributor
timestamp: July 18, 2017, 06:15:33 am
content: Posted on 2017-07-18T06:16:44+00:00

author: mc172
author_rank: Frequent Contributor
timestamp: July 18, 2017, 08:43:00 am
content: Quote from: tggzzz on July 17, 2017, 10:08:44 pmEh? Please explain, I'm curious to understand!

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 18, 2017, 09:14:36 am
content: Hm... 59682F00 doesn’t really seem worth celebratingI'm holding out for Wed Dec 25 05:01:21 GMT 2041. It's even Christmas Day.(PS Although I can understand the obsession humans have for base 10)

author: Electro Detective
author_rank: Super Contributor
timestamp: July 18, 2017, 09:16:34 am
content: .If you can fit one of these in the shed, time zones are not a problem

author: tggzzz
author_rank: Super Contributor
timestamp: July 18, 2017, 09:47:00 am
content: Quote from: mc172 on July 18, 2017, 08:43:00 amRemember what happened on Sunday, 26 March 2017 at 01:00?And will happen on Sunday 29 October at 02:00, in the UK?

author: Jeroen3
author_rank: Super Contributor
timestamp: July 18, 2017, 09:57:52 am
content: Don't forget to account for general relativity.

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 18, 2017, 10:28:26 am
content: Quote from: Jeroen3 on July 18, 2017, 09:57:52 amWhat do they say? A man with one watch always knows the time, a man with....How about a man with six atomic clocks in the back of his car?http://www.leapsecond.com/great2016a/

author: tggzzz
author_rank: Super Contributor
timestamp: July 18, 2017, 10:33:07 am
content: Quote from: Jeroen3 on July 18, 2017, 09:57:52 am... another bag of worms.And, of course, there's the everyday problem of two clocks separated by a significant distance (and hence time), where "significant" is of the order of the tick durationThat's a fundamental problem; see Leslie Lamport's seminal work to find out the best that can be achieved. most frequently seen when trying to decide which version of a file is more recent, in a distributed file system.

author: mc172
author_rank: Frequent Contributor
timestamp: July 18, 2017, 12:53:40 pm
content: Quote from: tggzzz on July 18, 2017, 09:47:00 amRight, do you mean 01:59:59.5, then?

author: tggzzz
author_rank: Super Contributor
timestamp: July 18, 2017, 02:08:14 pm
content: Quote from: mc172 on July 18, 2017, 12:53:40 pmMaybe. Complicated and error prone, this time and calendar stuff

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 18, 2017, 02:26:22 pm
content: OK I admit it... interesting things do happen when humans and calendars are involved... I spent my New Year watching 23:59:60

author: alm
author_rank: Super Contributor
timestamp: July 18, 2017, 02:28:09 pm
content: Quote from: tggzzz on July 18, 2017, 02:08:14 pmAgreed. Two things that I would not develop myself if there is any way to avoid it:CryptographyTime/date handling

author: technix
author_rank: Super Contributor
timestamp: July 18, 2017, 03:00:37 pm
content: For me I usually just says F with time zones - it is the last thing I add into my code (along with other i18n/l10n stuff) and the core code is always based on some kind of epoch for time manipulation. Most code uses either UNIX epoch (1970-01-01T00:00:00Z, counting seconds using integers) orNeXTSTEP epoch(2001-01-01T00:00:00Z, counting seconds using double-precision float point numbers.)

author: tggzzz
author_rank: Super Contributor
timestamp: July 18, 2017, 03:04:25 pm
content: Quote from: alm on July 18, 2017, 02:28:09 pmWe are in violent agreement.

author: tggzzz
author_rank: Super Contributor
timestamp: July 18, 2017, 03:08:34 pm
content: Quote from: technix on July 18, 2017, 03:00:37 pmSometimes it isn't possible to avoid themIn one incarnation I was developing soft realtime mobile phone charging systems. The tariff depended on the time of day/week/month/user and marketing whims. If the call is originated in Western Australia, terminated in the UK, and the billing system is in Canada, you have to be very careful which timezone you are meant to be using!

author: alm
author_rank: Super Contributor
timestamp: July 18, 2017, 03:18:48 pm
content: Quote from: tggzzz on July 18, 2017, 03:08:34 pmAnd then you find out that the energy company was usingMicrosoft Excelfor billing, and you have to modify your date handling to match theirs.

author: @rt
author_rank: Super Contributor
timestamp: July 18, 2017, 03:29:56 pm
content: I spent too much time explaining to my boss that people on 1st floor should be paid more than people on ground floor,because the people working on the 1st floor adhered to a clock on the ground floor (with regard to working hours).

author: NivagSwerdna
author_rank: Super Contributor
timestamp: July 18, 2017, 03:52:08 pm
content: The same effect causes GPS clocks to run fast by 45us/day... it's a big effect!

author: technix
author_rank: Super Contributor
timestamp: July 18, 2017, 05:23:29 pm
content: Quote from: tggzzz on July 18, 2017, 03:08:34 pmEpoch-ify the time at ingress. Define time periods always on UTC internally, you are set.

author: r3bers
author_rank: Contributor
timestamp: April 02, 2018, 11:26:06 pm
content: The Empire on which the sun never sets.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: April 03, 2018, 07:20:57 am
content: An interesting list: falsehoods programmers believe about timehttp://infiniteundo.com/post/25509354022/more-falsehoods-programmers-believe-about-time