Author Topic: About time zones...  (Read 9370 times)

0 Members and 1 Guest are viewing this topic.

Offline VinzCTopic starter

  • Regular Contributor
  • *
  • Posts: 217
  • Country: be
  • See you later, oscillator.
About time zones...
« on: July 16, 2017, 01:37:14 pm »
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).
« Last Edit: July 16, 2017, 02:29:13 pm by VinzC »
 
The following users thanked this post: SeanB

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #1 on: July 16, 2017, 02:34:17 pm »
Anything to do with time and dates is more difficult than you imagined. And that includes recursion.

Let's start with simple questions:
  • 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?
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline VinzCTopic starter

  • Regular Contributor
  • *
  • Posts: 217
  • Country: be
  • See you later, oscillator.
Re: About time zones...
« Reply #2 on: July 16, 2017, 09:17:27 pm »
Anything to do with time and dates is more difficult than you imagined. And that includes recursion.

Let's start with simple questions:
  • 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?
Well, the answer is simple. It just depends on where you are and when you ask the question.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #3 on: July 16, 2017, 09:46:07 pm »
Anything to do with time and dates is more difficult than you imagined. And that includes recursion.

Let's start with simple questions:
  • 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?
Well, the answer is simple. It just depends on where you are and when you ask the question.

Assume here and now. What's your answer?
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline VinzCTopic starter

  • Regular Contributor
  • *
  • Posts: 217
  • Country: be
  • See you later, oscillator.
Re: About time zones...
« Reply #4 on: July 16, 2017, 09:57:44 pm »
Assume here and now. What's your answer?
Define "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 ;-) .
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #5 on: July 16, 2017, 10:00:12 pm »
Assume here and now. What's your answer?
Define "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 ;-) .

All valid, but none of that changes the answers :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2840
  • Country: 00
Re: About time zones...
« Reply #6 on: July 17, 2017, 02:47:07 pm »
All valid, but none of that changes the answers :)
Of course it does. Some places observe daylight savings, others do not.

Anything to do with time and dates is more difficult than you imagined. And that includes recursion.

Let's start with simple questions:
  • 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?
Assuming we are talking UTC (so no daylight savings or politicians changing timezones):
  • 1000 milliseconds in a second
  • 59, 60 or 61 seconds in a minute (leap seconds)
  • 60 minutes in an hour
  • 24 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 century
What 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.

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: About time zones...
« Reply #7 on: July 17, 2017, 03:02:12 pm »
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 advise https://en.wikipedia.org/wiki/Barycentric_Dynamical_Time

 ;)

PS
1000 milliseconds in a second
Nothing wrong with that statement... in fact it is the definition of a milli.   1000 milliaardvarks in an aardvark
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #8 on: July 17, 2017, 04:13:11 pm »
All valid, but none of that changes the answers :)
Of course it does. Some places observe daylight savings, others do not.

Anything to do with time and dates is more difficult than you imagined. And that includes recursion.

Let's start with simple questions:
  • 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?
Assuming we are talking UTC (so no daylight savings or politicians changing timezones):
  • 1000 milliseconds in a second
  • 59, 60 or 61 seconds in a minute (leap seconds)
  • 60 minutes in an hour
  • 24 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 century
What pitfalls did I miss (step into)?

In 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 you have to 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.

Quote
*) 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.

How narrow minded and parochial; a common fallacious assumption :)

One calendar has up to 19 months of 19 days - plus a 4 or 5 days that aren't in months.
« Last Edit: July 17, 2017, 04:20:31 pm by tggzzz »
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #9 on: July 17, 2017, 04:17:32 pm »
I would recommend against using UTC, the length of the day varies considerably during the year due to the earth's rotation varying. 

Sometimes UTC is precisely the most appropriate definition of time; it all depends on how you are using time.

Quote
1000 milliseconds in a second
Nothing wrong with that statement... in fact it is the definition of a milli.   1000 milliaardvarks in an aardvark

Not quite as simple as that. Leap seconds are added/subtracted at convenient instants, not when a definition of time has shifted by 1000ms.

There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: About time zones...
« Reply #10 on: July 17, 2017, 06:06:48 pm »
Not quite as simple as that. Leap seconds are added/subtracted at convenient instants, not when a definition of time has shifted by 1000ms.
Seconds 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).    ;)
« Last Edit: July 17, 2017, 06:08:48 pm by NivagSwerdna »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: About time zones...
« Reply #11 on: July 17, 2017, 06:15:36 pm »
Not quite as simple as that. Leap seconds are added/subtracted at convenient instants, not when a definition of time has shifted by 1000ms.
Seconds 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).    ;)
It'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.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #12 on: July 17, 2017, 08:01:18 pm »
Not quite as simple as that. Leap seconds are added/subtracted at convenient instants, not when a definition of time has shifted by 1000ms.
Seconds 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).    ;)

You appear to be confusing durations with calendars. They are fundamentally different and incompatible, despite their using similar units. And therein lies a lot of the complexity :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: About time zones...
« Reply #13 on: July 17, 2017, 09:31:23 pm »
You appear to be confusing durations with calendars. They are fundamentally different and incompatible, despite their using similar units. And therein lies a lot of the complexity :)
Hm... 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.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #14 on: July 17, 2017, 10:08:44 pm »
You appear to be confusing durations with calendars. They are fundamentally different and incompatible, despite their using similar units. And therein lies a lot of the complexity :)
Hm... 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.

Simple 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.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: About time zones...
« Reply #15 on: July 18, 2017, 04:44:06 am »
Practically you have to include DST; hence 23/24/25 is correct.

Which 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.

Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: About time zones...
« Reply #16 on: July 18, 2017, 04:54:51 am »
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 advise https://en.wikipedia.org/wiki/Barycentric_Dynamical_Time

 ;)

PS
1000 milliseconds in a second
Nothing wrong with that statement... in fact it is the definition of a milli.   1000 milliaardvarks in an aardvark

Well there goes a few more hours on Wikipedia and in the more obscure corners of the Interweb....
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2840
  • Country: 00
Re: About time zones...
« Reply #17 on: July 18, 2017, 05:00:30 am »
Practically you have to include DST; hence 23/24/25 is correct.
Why? Look at this 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 :P). So North Korea, which does not observe daylight savings, would be a valid pick.

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4067
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: About time zones...
« Reply #18 on: July 18, 2017, 06:15:33 am »

Posted on 2017-07-18T06:16:44+00:00
 

Offline mc172

  • Frequent Contributor
  • **
  • Posts: 487
  • Country: gb
Re: About time zones...
« Reply #19 on: July 18, 2017, 08:43:00 am »
Simple 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.

 :o Eh? Please explain, I'm curious to understand!
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: About time zones...
« Reply #20 on: July 18, 2017, 09:14:36 am »
Hm... 59682F00 doesn’t really seem worth celebrating

I'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)

 

Offline Electro Detective

  • Super Contributor
  • ***
  • Posts: 2715
  • Country: au
Re: About time zones...
« Reply #21 on: July 18, 2017, 09:16:34 am »
.
If you can fit one of these in the shed, time zones are not a problem  >:D



« Last Edit: July 19, 2017, 08:15:17 am by Electro Detective »
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19279
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: About time zones...
« Reply #22 on: July 18, 2017, 09:47:00 am »
Simple 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.

 :o Eh? Please explain, I'm curious to understand!

Remember what happened on Sunday, 26 March 2017 at 01:00?
And will happen on Sunday 29 October at 02:00, in the UK?
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4067
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: About time zones...
« Reply #23 on: July 18, 2017, 09:57:52 am »
Don't forget to account for general relativity.  |O
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: About time zones...
« Reply #24 on: July 18, 2017, 10:28:26 am »
Don't forget to account for general relativity.  |O
What 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/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf