[Music]
our second talk for this block uh is
Time and Time Again by uh
Yakov uh who is a principal software
engineer at we Global is that what you
do these days yes yeah um he's also an
occasional speaker an open source
contributor and yes a reverse engineer
and a hacker and a problem solver and an
amateur radio operator and yes he does
talk about Pokémon a lot um what he
hasn't said in his bio is was actually
the session co-chair the program
co-chair last year for Pon Au um so if
you had problems like last year trying
to decide which talk you were going to
because they're all scheduled against
each other you can just blame
Yakov he's here for you um thank you my
apologies and thank
you I'd like to start today by
acknowledging the warun people of the
kol nation as the traditional owners of
the land where we meet today and pay my
respect to their Elders past and
present past and present when I started
writing this B I was wondering how far
can you get through a talk on time
without actually mentioning time like
even a simple good morning you've got
one word and in acknowledgement of
country I counted about 32 and then I
suddenly realized now that today
mentions time and start gets you only
forward in it's very hard to escape time
time is very pervasive in everything we
do a while ago I was mindly scrolling
through memes on Facebook which is
pretty much all good for these days and
I came across a tech comedian please
forgive me I do not remember who it was
um I couldn't find again when I went
looking if you recognize this let me
know afterwards but it was a tech
comedian who was talking about the
perfect calendar design what would
happen if he got to rewrite the calendar
so it was easier something like this the
year would be made up of 52 weeks uh but
they would be divided into 13 months of
exactly four weeks each and they would
each contain seven days this would
simplify a lot of calculations cuz the
first day of every week and of every
month would be a Sunday the last day of
every week and the last day of every
month would be a Saturday and you could
figure out which day of the week
something was just by doing some simple
division and remainder really nice and
easy but if you're doing some very quick
maths in the back there um that doesn't
add up to 365 that gets to you 364 so we
need one more day so in order to account
for the imperfection of this calendar
we'll have an additional day inserted
between the end of one year and the
start of the next and this day doesn't
belong to any week it doesn't belong to
any month it doesn't belong to any year
so the year would end on Saturday then
you would have a day of limbo
and then you would have a
Sunday and instead of having leap years
we would just have two days of limbo you
get two days off two days do nothing and
then you'd start again on what would be
a Sunday now this sounds to me like
exactly the sort of calendar system you
would come from a certain orange website
arguing calendar system shouldn't be so
hard I managed to build myself one in
the weekend like it's not so bad
unfortunately this this isn't a loose
hypothetical from Tech comedy in the
early 20th century I found out later
this was known as the cotsworth plan or
the international fixed calendar and was
a serious Contender by the League of
Nations the predecessor to the United
Nations to be selected as the new
calendar
system the calendar would allow for
improved statistical comparisons of
monthly and quarterly data as all months
and all quarters would be in equal
length they'd have a whole number of
weeks they' all have the same number of
weekend the same number of Saturdays
like all your sales stats would line up
really really nicely and events such as
public holidays daylight savings changes
anything whose date FL uctuates to match
a particular weekday could now to be
assigned a fixed easily predictable date
this could have been
revolutionary but the impact of this on
religious life would have been very
significant the blank day finds no
origin that I can find in any religion
or any other previous culture so you
would have to shift you would have to
adapt like the Jewish weekly day of rest
Shabbat and that's why I wasn't here
yesterday it was a day of rest not
coming to a conference but that occurs
every seven days so on the current cism
it's every Saturday on this calendar
system well it would be every Saturday
the first year and then every Friday the
second year and every Thursday the third
year and so on so this would make it
really really difficult for Jews to
maintain observance of Shabbat along
with things like you know employment
kind of
important there's a story I was reading
a number of months ago um when I was
putting together this talk and it really
enlighted perfectly um one day Rabbi
abam kalmanovitz arrived Su in OS in
Poland he had an important matter andand
speak urgently with Rabbi YF hakon cuz
several major major rabbis were opposing
this calendar reform by the League of
Nations they didn't quite know how to
Ward it off Rob's response was actually
simple but genius not to prepare a
submission for the League of Nations or
to debate The Proposal but just request
a postponement for a later date like we
need a bit more time argued you need a
bit more time you need to properly
deliberate it and see what happens after
all if you put in a submission you could
risk an immediate and unwanted verdict
if request for delay you could end up
stalling The Proposal out entirely and
indeed that's what ended up happening
the League of Nations proposal reform
and deliberated from 1923 until
1937 where the outbreak of World War II
triggered the collapse of the League of
Nations and despite all the time and
money ped into this calendar reform it
disappeared along with the
league but League of Nations aren't the
only is the only time people have tried
to come up with different calendar
systems as another example and another
one I know from impacting Jewish life
the USSR I've tried this a couple times
they tried a calendar with a 5-day week
as seen here and a calendar with a well
it's officially a Six-Day week it shows
seven days but the public day of rest so
your weekend is every six days in the
blue square which yeah it's very
weird the point of all this is that time
is incredibly subjective what you think
of time what the League of Nations
thinks of time and what 3,000 years of
Jewish practice thinks of time and what
the Soviets thought of time these can
all compl completely separate things
despite the fact that they all coexist
in the same stream of time with no
alternate or parallel universes that we
know of we're living in the same time
but we experience it differently so
today let's have a look at time from
more than just the usual Western
perspective and let's mute my laptop
while I matter let's try and get a
better understanding of like what time
actually is if we can how we express and
communicate it and how we can use this
knowledge to avoid bugs build more
Reliable Software and build more
accurate computer systems for diverse
audience
a that mute didn't seem to work so if if
you can mute it from your end all
good so let's start with time but really
let's let's start by looking at space
they kind of go together without getting
into weird particle physics we all know
that two things can't really exist in
the same space cu the real world does
run with physics collisions enabled in a
hypothetical one-dimensional World
there'd only be two directions of
movement you can go left or you can go
right uh if you're in that world you
might consider it forwards or backwards
I don't don't know I've never lived in
one but this is severely limiting and it
to be honest it would be the worst game
of snake ever cuz you can't even turn
around like two things just can't share
the same coordinate you've got a number
line six and seven are different
spaces if you look at a a
two-dimensional world we know again you
can only have one thing at each
addressable point you can now move up
down left or right but you can't share
space with something else two things can
share an x coordinate or a y-coordinate
but not both on a screen like or like
this one or that one uh pixel only has
one color you can't have two things
occupying one pixel unless you you can
BL you can blend it but that changes it
into something else it's a third thing
it's not the first two combined and no
I'm not going to get into sub pixels
that's not the point of this in a
three-dimensional world we have the same
problem we have now six directions of
movement but again we can't share the
same physical space with something else
you can share two of your XY and Z
coordinates or Z for the Americans but
not all three if we could then I would
have a problem because gravity would
keep pulling me through this stage and
straight down like the fact that my feet
can't occupy the same space as my shoes
and my shoes can't occupy the same space
as the stage and the stage the floor and
so on is all that is stopping me from
being sucked up and burned by the fiery
core of the planet down below which is
really best not to think about in all
these cases though we have movement
because we have the additional dimension
of time time is often referred to as the
fourth dimension and it's interwoven
with space in both science such as
Einstein's theories about SpaceTime and
in popular culture such as Pokémon
Diamond and Pearl have the legendary
Pokémon of space and
time you can share all your Corners with
something else but as long as it's a
different time we take
turns time is what allows for things to
change the world's in a particular State
then the world's in a different state
and then it's in a different state yet
again as time flows things move grow age
and
Decay but how we perceive all of this is
entirely cultural there is no fundament
rules the universe or fundamental rules
computer science for how to describe
space or time how to describe chunks of
it how to describe the difference
between
them over the centuries space has been
measured in meters feet hand breads
light ears and so on for those who use
meters 1 meter was originally defined as
110 millionth of the distance from the
equator to the North Pole nowadays it's
defined as the distance traveled by
light in a vacuum in 1 299 millionth 729
458 of a second
which again is a certain measurement of
time the two are linked a second was
originally defined relative to a day you
divide they up into pieces and you land
up with a second so it would be 186,000
400th of a day nowadays it's measured as
the base unit uh based on the frequency
of cesium 133 we're going back into
particle physics these evolved from the
previous definitions into the SI system
the International System of Units which
is the general system used to measure
things in most countries all around the
world and officially recog recognized by
their governments although that's how we
officially recognize it on paper with
mathematical formula that's not
necessarily how we perceive of time or
think of it on a regular
basis Humanity in storytelling and in
art regularly dreams of being able to
stop time or travel through time
forwards or backwards or even what could
exist Beyond
time but although we all move through
time at a rate of exactly 1 second per
second no more and no less we usually
use other Expressions to describe a Time
rather than only seconds like this talk
SL is 30 minutes uh it's not 16 half
billion oscillations of cesium we don't
think of it like that it started at 10 2
not at some number of oscillations since
well when exactly we need a common
reference point if we want to make sure
that you and I are talking about the
exact same point in
time so let's talk about
calendars calendars are well they
describe the continuous stream of time
by dividing it into addressable chunks
relative to some common reference point
so we can schedule things like talks
breaks shipments meetings standups oo
and so
on as I mentioned at the start there was
the idea of the international fixed
calendar but that went nowhere the one
that most of you are probably familiar
with would be the Gregorian calendar the
Colonial calendar of Christianity named
after Pope Gregory the
13th this is what you would think of by
default we've got our 12 months 7 days
in a week days start and end at midnight
and so on and and it is full of edge
cases it replaces predecessor the Julian
calendar named after juliia Caesar of
the Roman Empire who established it and
that was a modification of the original
Roman Calendar established by King
Romulus who founded Rome be honest how
often do you think about the Roman
Empire for me it's whenever I look at a
calendar now if I ask many of you here
what's the best way to express a date or
time value you would probably refer me
to ISO 8601 which is the date and time
format specified by the international
standards organization I see a few nods
so definitely some fans here but
unfortunately being an ISO standard you
have to pay quite a bit of money to get
your hands on the actual text
fortunately for me the US Library of
Congress has a what looks like a draft
version up from 2016 uh publicly
available and that quite clearly states
this International standard uses the
Gregorian calendar for the
identification of calendar days so Roman
and Christian colonization have been so
effective that this has become the
global standard if you want to express
dates and times from any other calendar
system you're out on your own the
standards organization doesn't cover you
python does something very similar the
date time type doesn't seem to work well
with other calendar systems and the
documentation says assuming the current
Gregorian calendar always was and always
will be in effect which is hilarious cuz
it probably won't always will be I'm
sure we'll come up with something else
and another set of edge cases to program
for it also definitely wasn't always was
absolutely not also it it explodes if I
try and represent a date not sanctioned
by the pope I've got a 13th month here
and doesn't like that I actually find
this quite funny because before juliia
Caesar the Roman Calendar had extra
inter calorie months so this idea of
there only being 12 months is a
relatively recent
thing but before the Gregorian calendar
we had the Julian calendar and this is
still used today by some sects of
Christianity as well as apparently the
Berber people of Northern Africa but it
was also the calendar used all across
Europe PRI prior to Pope Gregory's
calendar re form so if you're trying to
do anything with dates before the late
16th century you're going to have to do
a whole bunch of adjustments to
translate between the two calendar
systems and since there was no ntp back
then and no widescale coordination the
change over between calendars is also
region specific so good luck and May the
force be with
you the next calendar I would expect
you'd be somewhat familiar with is the
financial
calender I haven't even gotten into it
yet this is almost exactly the same as
the Gregorian calendar except the year
ends with the month of June and starts
with the month of July that's right the
the year increments on the first day of
the seventh month usually this is
distinguished by the FY monik on year
numbers or usually it's actually partial
year numbers we have fy2 FY 26 we are
building up to another Y2K problem at
this
point following this we also then have
the idea of dividing these into quarters
with quarter one q1 being July through
September Q2 being October through
December and so on disclaimer if any
foreigners or people watching the
recording this is Australia other
countries do similar things including I
think somebody I don't remember I was
talking to had February to February
that's why why why be off by one month
but like different countries do
different things different economic
systems by the way there also something
called the iso week numbering year or
the iso year the international fixed
calendar didn't Disappear Completely so
Financial purposes they devised a
calendar which looks almost exactly like
the Gregorian calendar except every year
has 52 or 53 weeks and every week starts
on a Monday and ends on a
Sunday this year is using a number of
libraries if you try and format the year
as y y y y in capitals rather than y y y
y in lowercase I don't believe python
has this I don't believe net has this
I'm pretty sure Java has this and I know
Swift and Objective C have this um so
keep an eye out for this in your code as
it can end up being wrong right around
New Years when everyone's on holiday uh
I also haven't checked see if like
beware interrupt deal with this or not
so just keep an eye out for uppercase
wise also if you're programming you
probably don't want all four wise not
every calendar is up to four digits at
the moment so just one wi it'll fill it
in and then the next calendar that I'm
the most familiar with is the Hebrew
calendar or the Jewish calendar depends
what framework Ork you're talking about
um I don't know if it is a name it's
just Lu which is a Hebrew word for
calendar um and instead of being based
on oscillations of an atom or how long
it takes the Earth to complete a full
orbit of the Sun days are based on
Sunrise or Sunset it's days run from
Sunset to Sunset uh months are based on
the orbit of the moon around the earth
and years are 12 or 13 months so that we
don't get out of work with the seasons
you know your Harvest Festival needs to
be when you're having your
Harvest interestingly the Hebrew
calendar does share a property with
financial Year and that is the last day
of the year is the last day of the sixth
month and the first day of the year is
the first day of the seventh month
annoyingly I've yet to see a single
framework support this both objectiv C
and Swift treat the first day of the
year as also the first day of the first
month and when I complained to Apple
about this they said they can't do
anything they just raply BYU it's up to
International components for Unicode to
do that also in the times of the temple
as pictured here um the new month had to
be declared by the courts when someone
actually saw the new moon so if it was
cloudy and everybody slept in uh all
your computer calculations are
wrong there's also the Chinese calendar
also known as the Luna calendar um which
like the Hebrew calendar is Looney solar
you've got your lunar months and then
you add an extra one so it doesn't get
out of out of whack with a solely year
despite being called the Chinese
calendar modern China mostly use the
Gregorian calendar thanks to
colonization um and it's mostly used for
holidays such as the Chinese New Year
and the Lantern Festival my only
interaction with it is when Chinese
colleagues go on holiday for New Year's
and when Pokémon OverWatch have
promotional
events and lastly I couldn't not mention
the Islamic calendar which is famous
among calendar systems for being
entirely lunar so months follow the moon
a year is 12 months that ends up being
354 355 days and so since that's shorter
than a solar year it's not in sync with
the previous calendar systems at all so
if you track for example the month of
Ramadan when Muslims you may have
co-workers might be you um who fast it
gets earlier and earlier every year if
your primary frame of reference is a
solar calendar that said there is
apparently a solar variant used in Iran
but I don't know how that
works so let's talk about
software now given everything I've said
about being cultural and contextual
there is no one right way to write code
that makes it perfect but I do have some
tips that should hopefully help and the
first one is learn your calendar systems
the entire software industry loves to
write software relating to fields that
were not experts in and then we also
don't consult the experts and then we
wonder why our big multic cloud
hyperscaling whatever doesn't actually
solve the problem that we set out to
solve in the first place learn how your
calendar Works learn about leap days or
leap months learn about time zones
savings leap seconds time drift all the
other ways your program may
break go read one of the many
compilations of falsehoods that
programmers believe about time there are
a lot of them I found they are all good
and I always come away surprised in
learning something new that I didn't
know beforehand whether it's the idea
that some Muslim countries suspend and
resume daylight savings around Ramadan
or in 2013 in the West Bank Israelis and
Palestinians were living in different
time zones because Israel and the PA had
different start and end dates you could
be neighbors and be an hour apart there
is always something funky and
interesting to learn about
time if you're just throwing dates
around without understanding what they
mean and how they work then let me draw
your attention to this classic quote
from Charles Babbage on two occasions
I've been asked pray Mr babage if you
put into the machine wrong figures will
the right answers come out I'm not able
rightly to apprehend the kind of
confusion of ideas that could provoke
such a question to be honest I thought
we had long understood theide of garbage
in garbage out until these guys came
along and they wanted garbage in
business
out but once you've learned how your
calendar system works you might then be
tempted to run off and write all the
necessary arithmetic and logic yourself
like cryptography please
don't take your new found knowledge and
use it to build test cases and make sure
your software Works in as many ways and
as many scenarios as possible but lean
upon the standard libraries when you
have them to do the calculations
correctly I don't believe python has all
the calendar built in there are some
packages other Frameworks like net and
Swift Objective C do have a lot of stuff
built in let me share with a let me
share with you a story of what happens
if you
don't on February 28th 2012 at 5:45 p.m.
Pacific Time Microsoft became aware of
an issue impacting Windows Azure service
Management in a number of regions by the
way this predates naming of Microsoft
Azure can anybody think maybe what might
have gone wrong here does does that date
mean anything to
you uh what might have happened in other
time
zones here's here's their post Mor blog
post they're talking about the
connection between the hypervisor and
the guest VM there's a transfer TLS
certificate that goes between them it
says when the ga creates the transfer
certificate gives it a one-ear validity
range it uses midnight us of the current
day as availed from date and one year
from that date as the valid two date the
leap day bug is that the ga calculated
the valid two date simply by taking the
current date and adding one to its year
you got February 29 2013 which does not
exist and caused it all to fail so
basically what they should have done was
called the ad years function assuming
it's net cuz Microsoft are all net all
the way down uh called add years
function to add one year instead most
likely they deconstructed the date in
invalid manner now you can argue if like
one year after 28th of February should
be one year after 29th of February
should be the 28th of February or if it
should be the 1st of March
uh I would hope that this's a solv
problem particularly when you have like
inter calorie months because your whole
month doesn't exist you can't just shift
one day but either way um if you call AD
years it might be off by day but it
doesn't crash and definitely doesn't
bring down the entire management plane
of a global Cloud compute platform so
use your libraries they are there to
help unless they're wrong in which case
File bugs to help everyone and learn
them and learn what they do like learn
the difference between upper KY and the
lower KY read the documentation really
thirdly make sure that when you have
computer systems plural um talking time
that they speak the same language
computers represent time in a few
different ways you have to make sure
that when two computers talk they mean
the same thing for example Unix machines
famously count the number of seconds
since 1st of January 1970 Apple machines
internally have an Epoch 31 years later
on the 1st of January 2001 I know uh
Steam and some valve software have
internal data structures where they have
an internal Epoch of the 1st of January
2005 in Seattle
so that's specific Standard time that's
not even
UTC and uh if you watch Tom Eastman's
talk on U IDs in devoops on Friday the
uid V1 spec has a time stamp in 100 nond
intervals from Midnight on the 15th of
October 1582 which is the date of
Gregorian reform to the Christian
calendar in France remember it wasn't
Global this also raise an additional
Point here each interval is 100 Nan some
systems will use seconds some will use
millisec seconds I've definely had that
bug before the time looks wrong you
divide by th now it looks right so just
make sure that both ends are speaking
the same
language and save all the data you need
if you're saving date and time data to a
database uh make sure you have
everything time itself is not enough
time and UTC offset is sometimes not
enough as well you may need a time zone
if you have it so like Melbourne or New
York so that you can add dates subtract
dates figure out daylight savings
changes and if you are dealing with
multiple calendars make sure you keep
that them as well and on that note and
there's a personal plea but pleasa
support multiple calendars in personal
applications they should be able user
should be able to use a calendar that
they know best for Relevant events so
particular particularly for apps like
calendars Diaries even a to-do list a
date that has meaning in one calendar
system could be meaningless converted
into another if I look at a date and
it's mid-February I don't know what that
means if it says Chinese New Year I have
some idea Apple do this pretty well in
the phone contacts app you can log
someone's birthday in the Gregorian
calendar in another calendar system so
you can celebrate their birthday with
them culturally in the right calendar
where they observe their birthday
unfortunately you can't select all three
Calenders so any Arabic Jews in China
are completely out of luck they also
don't support this for other events like
wedding anniversaries or calendar events
like holidays which annoys
me and on Apple watch which doesn't
actually have enough room to display the
entire Hebrew date here uh Apple just
translate the current Gregorian date to
the matching Hebrew date they forgot
what I said earlier about the Days
running from Sunset to Sun on set rather
midnight to midnight so my watch is
wrong for about 4 to 8 hours every
single day depending on the time of year
and my geographic location and in theory
this shouldn't be hard to get right
there's already a watch complication
with sunrise and sunset times so the OS
knows what it's doing it just doesn't
piece together everything this comes
back to my first point if you're writing
code to do something make sure you know
what that thing is so you have a decent
chance of getting it
right now back in 2013 2014 I was
working on iPhone app that never went
anywhere and also in 2014 I took a trip
to Seattle for the Dota 2 International
championships and while I was there I
was trying tdd I ran I wasn't competing
by the way I was just spectating but I I
I ran all my unit tests and and two
suddenly failed and I had a look and I
had a logic bug that only worked in
positive UTC offset so my code worked
anywhere east of Greenwich failed
anywhere west of Greenwich for overseas
companies as well can be really handy to
have staff on the East Coast of
Australia with UTC plus 10 or 11 so if
you hit a bug at midnight UTC we're
awake we're ready to go you're not
rolling stuff out of bed on call they're
half asleep grabbing coffee trying to
figure out what's wrong on the computer
also if you have staff in other parts of
the world that don't take holidays
around the Goran New Years and you get a
bug like an ISO week week year bug or
something like that um you have to get
someone in to fix that they might be on
holidays if you live somewhere without
daylight savings there are bugs you may
never find so if you can put your
software through more diverse scenarios
earlier you find bugs earlier you fix
them earlier hopefully your software's a
a bit more stable and lastly be aware of
significant edge cases in how computers
represent time the 238 bug where the
number of seconds since 1970 no longer
fits into a s 32-bit integer is still
coming upon us and from what I read a
while ago it's mitigation with 64-bit
time in Fedora had a pretty disastrous
roll out and had to be rolled back so be
prepared for that or do what i' do book
some leave in advance for 2038 so that's
not your problem and if you're wondering
what the second one is um that's the
small datetime column limit in Microsoft
SQL Server when I put that leave in we
had an unhandled exception somewhere so
if I'm still around and working by then
uh I'll see you two days later thank
[Applause]
you thank you Yakov I think we've got a
couple of minutes for questions if
anyone's gotten
in no we are all in some kind of weird
time yes
would give a mic
please thank you yob so you've mentioned
interoperability and because of the web
any language that you you write you have
to interoperate with JavaScript what are
your recommendations in terms of
libraries of practices for python
JavaScript making sure that you're doing
the same I haven't worked a huge amount
with JavaScript I mean my initial
reaction is please don't um but it's
something I'd have to look into
uh indeed any other
questions all righty thanks everyone uh
10-minute break