Fireship · @fireship
Time… a programmer's worst enemy // The Code Report
Uploaded March 17, 2022 · Length 3:06
Summary
The video discusses the complexities of time, including time zones, leap seconds, and the Gregorian calendar, and proposes alternatives like the Cotsworth plan.
- time zones
- leap seconds
- gregorian calendar
- temporal api
- javascript dates
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:01
it is march 17 2022 and you're watching
- 0:04
the code report it's about time we had a
- 0:06
talk about time you would think it's a
- 0:08
pretty simple concept time began on
- 0:10
january 1st 1970 with the unix epic at
- 0:13
any moment we can get the number of
- 0:15
milliseconds elapsed from this date on
- 0:16
any computer using a method like date
- 0:19
now this is called incremental time but
- 0:21
one problem is that the earth doesn't
- 0:22
rotate evenly because it's actually flat
- 0:24
and the international earth rotation
- 0:26
service occasionally mandates a leap
- 0:28
second where an additional second is
- 0:30
added to the last minute of the day
- 0:31
things start getting weird when we talk
- 0:33
about time zones which are calculated
- 0:35
relative to greenwich mean time on the
- 0:37
pacific we subtract eight hours but in
- 0:39
newfoundland they only subtract three
- 0:40
and a half hours and in nepal they add
- 0:42
five and three quarters then daylight
- 0:44
savings comes around and all the time
- 0:46
zones change except in places like
- 0:48
arizona and hawaii that don't do a time
- 0:50
change in the south pacific they're 13
- 0:52
hours ahead which requires them to skip
- 0:54
an entire day you could celebrate new
- 0:56
year's on christmas island spend the
- 0:57
entire next day recovering from your
- 0:59
hangover then fly to jarvis island in
- 1:01
time to celebrate new year's eve again
- 1:03
now when it comes to the entire year the
- 1:05
gregorian calendar is a ridiculous
- 1:06
abstraction some months have 28 days
- 1:08
while others have 31 but every other
- 1:11
counting system we use like weeks and
- 1:12
days have consistent intervals it
- 1:14
doesn't have to be this way the
- 1:16
cotsworth plan which was presented in
- 1:17
1902 divides the year into 13 months
- 1:20
each month with four weeks or 28 days
- 1:23
with one rest day somewhere in the
- 1:24
middle it makes so much more sense and
- 1:26
aligns better with the lunar cycle for
- 1:28
developers it would make the complicated
- 1:29
matter of finding the duration of
- 1:31
multiple months a simple matter of
- 1:33
multiplying by 28 but there may be some
- 1:35
good news when it comes to keeping track
- 1:36
of time there's a bill going through
- 1:38
congress right now to get rid of
- 1:39
daylight savings honestly it doesn't go
- 1:41
far enough and i wish they would also
- 1:42
get rid of the gregorian calendar this
- 1:44
could be bad news though for low-level
- 1:46
systems programmers who figured out all
- 1:47
these weird rules with time zones i
- 1:49
imagine this is the type of code that
- 1:50
nobody wants to touch but if we get rid
- 1:52
of daylight savings somebody will have
- 1:54
to go in there and change things
- 1:55
speaking of changes there is a stage 3
- 1:57
proposal for the temporal api in
- 1:59
javascript which would make it much


