It's about TIME David Hoppe @hopasaurus hopasaurus@gmail.com It's - - PowerPoint PPT Presentation

it s about time
SMART_READER_LITE
LIVE PREVIEW

It's about TIME David Hoppe @hopasaurus hopasaurus@gmail.com It's - - PowerPoint PPT Presentation

It's about TIME David Hoppe @hopasaurus hopasaurus@gmail.com It's time, so what! What is Time? What is a day? What is an hour? What is a minute? What is a second? Lets start at the beginning... What is a Day? How is time measured? By


slide-1
SLIDE 1

It's about TIME

David Hoppe @hopasaurus hopasaurus@gmail.com

slide-2
SLIDE 2

It's time, so what!

slide-3
SLIDE 3

What is Time?

What is a day? What is an hour? What is a minute? What is a second?

slide-4
SLIDE 4

Lets start at the beginning... What is a Day?

slide-5
SLIDE 5

How is time measured?

By the day Sundials Mechanical Clocks Electronic Clocks

slide-6
SLIDE 6

Things get weird!

  • We start to notice things.
  • Hours are not uniform between the seasons

– Sundials and mechanical clocks don't always agree

  • Days are not always the same length

– As clock get more precise we notice accuracy

slipping

slide-7
SLIDE 7

The equation of time

  • "Tijdvereffening-equation of time-en" by Clem Rutter, Rochester, Kent. - Originally from nl.wikipedia; description page is (was) here * 7 jan

2005 23:57 Willy Leenders 549x375 (49.479 bytes) (grafiek tijdsvereffening, eigen creatie)Modifications 2011:Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Tijdvereffening-equation_of_time- en.jpg#mediaviewer/File:Tijdvereffening-equation_of_time-en.jpg

slide-8
SLIDE 8

Which one is “right”?

slide-9
SLIDE 9

Time “Standards”

  • Atomic Time (TAI)
  • Universal Time (UT)

– UT0, UT1

  • Coordinate Universal Time (UTC)
  • Dynamical Time
  • Geocentric Coordinated Time
  • Barycentric Coordinated Time
  • Sidereal Time
slide-10
SLIDE 10

Leap Second?

INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS) SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE SERVICE DE LA ROTATION TERRESTRE DE L'IERS OBSERVATOIRE DE PARIS 61, Av. de l'Observatoire 75014 PARIS (France)

  • Tel. : 33 (0) 1 40 51 22 26

FAX : 33 (0) 1 40 51 22 91 e-mail : services.iers@obspm.fr http://hpiers.obspm.fr/eop-pc Paris, 5 January 2015 Bulletin C 49 To authorities responsible for the measurement and distribution of time UTC TIME STEP

  • n the 1st of July 2015

A positive leap second will be introduced at the end of June 2015. The sequence of dates of the UTC second markers will be: 2015 June 30, 23h 59m 59s 2015 June 30, 23h 59m 60s 2015 July 1, 0h 0m 0s The difference between UTC and the International Atomic Time TAI is: from 2012 July 1, 0h UTC, to 2015 July 1 0h UTC : UTC-TAI = - 35s from 2015 July 1, 0h UTC, until further notice : UTC-TAI = - 36s

slide-11
SLIDE 11

Why do we need leap seconds?

slide-12
SLIDE 12

How does all this affect me?

slide-13
SLIDE 13
  • "QSL card sent to listener confirming reception of WWV from Maryland - 194007" by http://tf.nist.gov/images/radiostations/wwv40.jpg;. Licensed under

Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:QSL_card_sent_to_listener_confirming_reception_of_WWV_from_Maryland_- _194007.jpg#mediaviewer/File:QSL_card_sent_to_listener_confirming_reception_of_WWV_from_Maryland_-_194007.jpg

slide-14
SLIDE 14

NTP and friends

  • Automatic time synchronization between hosts.
  • Difficult to agree on inserting leap seconds
  • More difficult to remove them
slide-15
SLIDE 15

Time Bugs

slide-16
SLIDE 16

ZUNE 30

  • December 31st, 2008 lockup
  • Finger pointing
  • Toshiba did it too (ever heard of Gigabeat S?)
  • It was Freescale's fault
  • Just fudge the clock
slide-17
SLIDE 17

Excel Bug

  • Excel pretends that February 29, 1900 exists
  • It doesn't
  • Why?
  • Lotus 1-2-3 started it.
slide-18
SLIDE 18

Y2K

  • Lets just use the last two digits for the year
  • It will save space
  • What could possibly go wrong?
slide-19
SLIDE 19

Y2.038K

  • Cause: using a 32bit signed int for storing time
  • AOL learned early
  • Some have yet to learn
  • Really, you didn't learn from Y2K???
slide-20
SLIDE 20

Tips for dealing with date/time:

  • Don't write your own parser
  • Don't do your own math
  • Be careful with local time vs. UTC Time
  • Know how the time is being stored

– Will it work until you retire? – When is the “end” of time?

  • Know how much precision/accuracy is needed.
  • Wrap access of the time from the system.
slide-21
SLIDE 21

Testing Time

  • Don't change the time on your server...
  • Check Leap year

– February 29 and December 31

  • Check non-Leap year
  • What will happen on a leap second?
  • What happens with an invalid date?

– February 30, 2015?

  • Don't hard code dates into your tests
slide-22
SLIDE 22

How should a Date be written?

http://xkcd.com/1179/

slide-23
SLIDE 23

Fun facts

  • Watch crystals
  • Metric time
  • How to tell a real Rolex from a fake?
  • Who is in charge of time?
slide-24
SLIDE 24

End of Time?

slide-25
SLIDE 25

What time is it now?

slide-26
SLIDE 26

It's about TIME

David Hoppe @hopasaurus hopasaurus@gmail.com

slide-27
SLIDE 27

It's time, so what!

A while back I was working on a project involving Receiving GPS signals and forwarding the data to a

  • server. GPS signals contain the current time. AND it

is a very accurate representation of the current time. HOWEVER when the signals got to the server the time was reported to be IN THE FUTURE!

slide-28
SLIDE 28

What is Time?

What is a day? What is an hour? What is a minute? What is a second?

In Book 11 of St. Augustine's Confessions, he ruminates on the nature of time, asking, "What then is time? If no one asks me, I know: if I wish to explain it to one that asketh, I know not." A second was:1/86400th of a day The second is the duration of 9 192 631 770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium 133 atom.

slide-29
SLIDE 29

Lets start at the beginning... What is a Day?

. Do the siderial time exercise. This will start to give a sense that all is not as it seems.

slide-30
SLIDE 30

How is time measured?

By the day Sundials Mechanical Clocks Electronic Clocks

slide-31
SLIDE 31

Things get weird!

  • We start to notice things.
  • Hours are not uniform between the seasons

– Sundials and mechanical clocks don't always agree

  • Days are not always the same length

– As clock get more precise we notice accuracy

slipping

We start to notice things Hours are not uniform Days are not always the same length.

slide-32
SLIDE 32

The equation of time

  • "Tijdvereffening-equation of time-en" by Clem Rutter, Rochester, Kent. - Originally from nl.wikipedia; description page is (was) here * 7 jan
2005 23:57 Willy Leenders 549x375 (49.479 bytes) (grafiek tijdsvereffening, eigen creatie)Modifications 2011:Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:Tijdvereffening-equation_of_time- en.jpg#mediaviewer/File:Tijdvereffening-equation_of_time-en.jpg

http://en.wikipedia.org/wiki/Equation_of_time So people figured out that the sun dial and the mechanical clock wouldn't agree all the time so they cracked open their history books and looked up this “ptolemy” guy who did a lot of math in ancient egypt and figured this all out for them already. This is partially due to the ecentricity of Earth's orbit also partially due to the Obliquity of the elipctic (pretty sure we humans refer to this as the tilt of the axis) The total variation from one extreme to the other ends up being about half an hour.... whatever an hour is. So now we have two time “standards” Solar time and Mechanical time. Or Apparent time and Mean time.

slide-33
SLIDE 33

Which one is “right”?

slide-34
SLIDE 34

Time “Standards”

  • Atomic Time (TAI)
  • Universal Time (UT)

– UT0, UT1

  • Coordinate Universal Time (UTC)
  • Dynamical Time
  • Geocentric Coordinated Time
  • Barycentric Coordinated Time
  • Sidereal Time

Atomic Time (TAI) – International Atomic Timescale based on a “large number” of atomic clocks Universal Time (UT) is counted from 0 hours at midnight with the unit

  • f duration being the mean solar day (a solar day adjusted to be

as uniform as possible dispite variations in Earth's rotation) UT0 and UT1 are related. Coordinated Universal Time (UTC) differs from TAI by an integral number of seconds. UTC is kept within 0.9 seconds of UT through the introduction of leap seconds. So far all leap seconds have been positive. UTC has replaced “GMT” as a standard. Dynamical Time, Geocentric Coordinated Time (TCG), Barycentric Coordinated Time (TCB), Sidereal Time (this one is interesting) Show the graph of “Variablility of Earth's rotation” And these are just the “Scientific” standards.

slide-35
SLIDE 35

Leap Second?

INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS) SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE SERVICE DE LA ROTATION TERRESTRE DE L'IERS OBSERVATOIRE DE PARIS 61, Av. de l'Observatoire 75014 PARIS (France)
  • Tel. : 33 (0) 1 40 51 22 26
FAX : 33 (0) 1 40 51 22 91 e-mail : services.iers@obspm.fr http://hpiers.obspm.fr/eop-pc Paris, 5 January 2015 Bulletin C 49 To authorities responsible for the measurement and distribution of time UTC TIME STEP
  • n the 1st of July 2015
A positive leap second will be introduced at the end of June 2015. The sequence of dates of the UTC second markers will be: 2015 June 30, 23h 59m 59s 2015 June 30, 23h 59m 60s 2015 July 1, 0h 0m 0s The difference between UTC and the International Atomic Time TAI is: from 2012 July 1, 0h UTC, to 2015 July 1 0h UTC : UTC-TAI = - 35s from 2015 July 1, 0h UTC, until further notice : UTC-TAI = - 36s

https://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat Yup leap second, it is Bulletin C put out by the IERS... the WHAT? IERS. International Earth Rotation

  • Service. They keep the globe spinning.
slide-36
SLIDE 36

Why do we need leap seconds?

Because Earth can't make up it's mind how fast we should be spinning.... I think this comes back to IEARS they must have a rotational speed committee.... probably works kind of like the committee that set the 12.5mph speed limit and the private road my friend lives on. http://tycho.usno.navy.mil/systime.html

slide-37
SLIDE 37

How does all this affect me?

Well, lets take a look at that, turns out that is does cause some issues. But look at it this way we get a free second every once in a while to do with what we please.... do you realize that business are losing millions by not billing for that second??? shh lets keep that our little secret.

slide-38
SLIDE 38
  • "QSL card sent to listener confirming reception of WWV from Maryland - 194007" by http://tf.nist.gov/images/radiostations/wwv40.jpg;. Licensed under
Public Domain via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:QSL_card_sent_to_listener_confirming_reception_of_WWV_from_Maryland_- _194007.jpg#mediaviewer/File:QSL_card_sent_to_listener_confirming_reception_of_WWV_from_Maryland_-_194007.jpg

Ok, we will get back to how it affects us in a little bit but first lets talk about how we sync up our clocks.. This brings us to WWV which is the oldest continuously operating radio station in the United

  • States. This station has been in continuous
  • peration since 1920. It started out broadcasting ag

reports in morse code... by 1922 its purpose was shifted to being the standard by which other stations could measure their signals. Back in that day frequency control was an issue so stations would tune themselves based on WWV being at a known

  • frequency. In 1945 it started to send out time

information by 1960 it was sending a format sutiable for automatic synchronization by machines. http://en.wikipedia.org/wiki/WWV_(radio_station)

slide-39
SLIDE 39

NTP and friends

  • Automatic time synchronization between hosts.
  • Difficult to agree on inserting leap seconds
  • More difficult to remove them

Ok, now we can circle back and tie up some loose

  • ends. Finish the GPS time story here

So synchronizing clocks involves dealing with these leap seconds. And in order to work with them and maintain synch we need to be able to have all the clock change as close to the same time as possible. And in the same fashion. Some ideas.... slow seconds... repeat a second.... insert an extra second. Also what time do they synchronize to? UTC https://www.meinberg.de/download/burnicki/Technical %20Aspects%20of%20Leap%20Second %20Propagation%20and%20Evaluation.pdf

slide-40
SLIDE 40

Time Bugs

So now that we can see that this is a complex issue, lets have some fun with it. Lets leave all the math and scientificals behind and looks at some past failures related to time.

slide-41
SLIDE 41

ZUNE 30

  • December 31st, 2008 lockup
  • Finger pointing
  • Toshiba did it too (ever heard of Gigabeat S?)
  • It was Freescale's fault
  • Just fudge the clock

So on December 31st, 2008 Microsoft discovered a bug in their Zune 30 player.... it have been out a couple years by that time so not sure how many were brand new Christmas presents at this point.... but really if you got Zune for Christmas... well its just not an iPod is it. Anyway they ALL locked up... let the finger pointing

  • begin. Turns out that Microsoft used the software

provided by one of the chip manufacturers for clock management and there was a serious flaw in the software for years with 366 days, that is to say LEAP years. Lesson learned from this? Don't trust your vendors too much.... also test for leap year on Feb 29 and also December 31st.

slide-42
SLIDE 42

Excel Bug

  • Excel pretends that February 29, 1900 exists
  • It doesn't
  • Why?
  • Lotus 1-2-3 started it.

To maintain compatibility with Lotus, Excel introduced “incorrect” behavior it was decided that “fixing” it would potentially break some systems that depended

  • n the incorrect behavior and limit acceptance of

Excel. Come on Excel if Lotus jumped off a bridge would you? No we got market share. Lesson learned... Sometimes bugs are ok

slide-43
SLIDE 43

Y2K

  • Lets just use the last two digits for the year
  • It will save space
  • What could possibly go wrong?

Yeah..... Well it was true, space was at a premium back in the

  • day. Was talking to my friend about this a while back

and space was a big issue and they knew this would be a problem but kicked the can down the road. Lesson learned – pay attention to the tradeoffs you are making and don't kick the can off the edge of the cliff.. you (or someone else) will have to deal with the ramifications of your trade off sooner or later.

slide-44
SLIDE 44

Y2.038K

  • Cause: using a 32bit signed int for storing time
  • AOL learned early
  • Some have yet to learn
  • Really, you didn't learn from Y2K???

So yeah, when counting seconds from 1970 you run

  • ut on January 19, 2038. We have a few years left

before this hits though right? Well that is what AOL thought until their webservers crashed in 2006. Someone had hard coded a timeout of ONE BILLION seconds into a config file... guess what? May 12, 2006 is ONE BILLION seconds before January 19, 2038... someone had a rough day. Lesson learned: just because one effect is far off does not mean others are not lurking closer in. Also did anyone learn anything from Y2K? Enough fun with bugs, lets talk more practically http://en.wikipedia.org/wiki/Year_2038_problem

slide-45
SLIDE 45

Tips for dealing with date/time:

  • Don't write your own parser
  • Don't do your own math
  • Be careful with local time vs. UTC Time
  • Know how the time is being stored

– Will it work until you retire? – When is the “end” of time?

  • Know how much precision/accuracy is needed.
  • Wrap access of the time from the system.

C++ has boost Java has Joda time C# has stuff built in JavaScript has moment.js and others which is really good cause the different browsers all have really messed up quirks that will drive you nuts. And so on. Writing your own is asking for bugs... but don't over trust,,, remember the Zune. Do some testing. Pay attention to how the time/date is being stored. Don't let the code come back to bite you. A nice wrapper around time access allows for easier testing and also you can change out the implementation in a single place if desired. Unless you like singing “Auld Lang Time”

slide-46
SLIDE 46

Testing Time

  • Don't change the time on your server...
  • Check Leap year

– February 29 and December 31

  • Check non-Leap year
  • What will happen on a leap second?
  • What happens with an invalid date?

– February 30, 2015?

  • Don't hard code dates into your tests
slide-47
SLIDE 47

How should a Date be written?

http://xkcd.com/1179/

slide-48
SLIDE 48

Fun facts

  • Watch crystals
  • Metric time
  • How to tell a real Rolex from a fake?
  • Who is in charge of time?

Watch crystals are cut so that they are most accurate when the watch is warm, that is being worn. Leaving a watch off for a significant amount of time will result in the watch drifting. Probably not a noticeable amount though. There have been several attempts at trying to introduce “Metric Time” in 1790 the French tried it.. In the 1990's Swatch took a go at it with “Swatch Internet Time” The fake keeps good time. BIPM is in charge of time, they are the ones that make the leap seconds happen.

slide-49
SLIDE 49

End of Time?

The scientists are at it again... they now have a clock so accurate that it isn't accurate.... see time is relative.. moving from here (floor) to here..(up high) there is a one part in 10^16 change in the rate of the passage of time... some students at the University of Colorado Boulder claim to have built a clock sensitive enough to be affected by these

  • movements. One would thing that Tom O'brian

(America's official timekeeper) would be concerned, but really he is excited about the possibilities for this

  • technology. Not for its usefulness in measuring time

but for the ability to measure things that affect time. http://www.npr.org/2014/11/03/361069820/new-clock- may-end-time-as-we-know-it

slide-50
SLIDE 50

What time is it now?