Time is a Social Construct – Daniel Cousineau – JSConf US 2019


Time is a Social Construct Daniel Cousineau
KATIE: How are we doing? Woohoo. Second to last talk. I am like simultaneously excited to go and
party, but also sad that this is ending. Like, three days kind of went by pretty quickly. I don’t know about you. But it did for me. So, next up we have Daniel Cousineau who is
gonna talk to us about how time is a social construct. And Daniel was kind of lame and I asked him
for a fun fact and he didn’t give me one. Whomp, whomp. But thankfully, I happen to know very well
the person who is the co organizer of Queens JS with him. And she told me that 
[ Laughter ] She gave me all the dirt. Thank you, Sara, she’s out there somewhere. I have no idea where. I can’t see. She gave me a couple of fun facts. One of which I’m not gonna tell you because
it will spoil something in his presentation. The other fun fact is he is a serial conference
organizer and he started out organizing PHP meetups and PHP conferences in Texas. Which, like, I write PHP too. So I’m like, yes, PHP. And then when he moved to New York, after
six months he loved Brooklyn JS so much he said, I want to get involved. And they said, we don’t need you. But you can make this other new thing if you
want. So, yeah. So, that’s  that’s the fun fact about Daniel. So, let’s give it up for Daniel. [ Applause ]
DANIEL: All right. Is this on? All right. Howdy, everybody. Okay. Got a little bit of that. So, as I said, I’m originally from Texas. I’m from Texas A&M. When someone guess up on stage and stays howdy,
and everyone says howdy back. Try this one more time. Howdy! I think I see one. You said that, I know it hurt a little bit. So, let’s jump right in. Time. Time is a social construct. This talk does not have a simple ending, does
not have any solutions. Time is truly a social construct. And as we know, social constructs are garbage,
so, using the transitive property of math, we can conclude that time is garbage. We want to believe it is simple because simple
is easy. But that simplicity doesn’t hold up to any
scrutiny. I’m your host for the evening, Daniel Cousineau. Find me on Twitter, pronouns he/him. A long time ago I peaked. You can see me peaking right here. This is a sign of the times. My most popular Tweet of all time was a joke
about how painful time is. My second most popular Tweet was also about
how painful time is. And I got a lot of replies. Some of which  others seized upon fruitier
interpretations. Others were laboring under the delusion that
there was an easy answer. Even the easy truths are not as complete or
as exhaustive as we would want. And I’m not the only one who had these problems. Everybody has these problems with time. So, let’s start with a simple problem to solve. Let’s say I had a button on my phone that
if I tapped it, it would dispense food for my cats at home. That’s a talk for the node bots people. Frances is out there somewhere. But I want to feed the cats at noon every
day otherwise they get angry and start destroying all of my things. Let’s get started. My physics teacher in high school taught me,
when you’re solving a problem, start by writing down what you know. Tomorrow, August 15th, I would like to feed
my cats at 12 p.m. Now, most wouldn’t ask questions beyond this. They wouldn’t ask any questions beyond this. They would just start digging into the project. But we want to dig in a little bit deeper
and we want to ask ourselves some deeper questions. What is 12 p.m.? To a computer system, it’s maybe a point on
a timeline, an arbitrary number in the scheme of things. But to a human, this time has context. I contend that 12 p.m. actually means nothing
to you. But sometime around lunch does. Halfway through my day does, when the sun
is overhead. These are things that have meaning to us that
we just have to attach to the number 12. Time for us and cats is relative and entirely
according to our perspective. There’s a problem, whose 12 p.m. is this? That’s a fairly recent question in human history. Us asking that question. All right. There we go. Since the dawn of time, or just a long time
ago, we follow the circadian rhythm, wake when the sunrises, eat at zenith and go to
bed when it’s set. Appointments made along this rhythm. Even the advent of the mechanical clock did
little to change. Merely giving a mechanical consistency to
the solar day. And during the industrial Revolution, this
efficiency was very key as we’ll allude to later. Despite having these clocks, weapon needed
our older, more traditional sun dials. We allowed our clocks to see that 12 p.m.
aligned with solar noon. It was taking advantage of the equation of
the development of time. Which took into account variances for Earth’s
orbit to see when a solar minute would be longer or shorter than a theoretical perfect
orbit with no variances. That’s all they’re capable of providing, if
you think about it. Clocks that we set were set over the course
of the year, the difference between the readings, longer shorter out and averaged to zero. This was mean solar time. And a local village set the clocks to the
time to eventually catch back up with itself. We called this the local meantime. Cities began adopting public clocks because
they were big and expensive things. We couldn’t really all have pocket watches. And those clocks would make it accessible. Local meantime for the surrounding community. Everybody could set their day based off of
the clock in the center of town. As cities grew, different areas have needs
of clocks. Courthouses would have a clock. Bureaucratic buildings need a clock. They need to be set to the same time. However, not all of them would be set to the
same time. Courthouses and other government buildings
would be set 10 minutes slow to give leeway for the appointments. Is your appointment at 12:00 and you’re caught
up in a three horse accident with cabbages all over the ground? Don’t worry, the court says it’s 11:55 in
the morning. But in the early 1800s, humankind had a radical
transformation of technology. There was no longer the workday ending with
the sunsetting. The Telegraph meant we could communicate over
long distances. And the advent of trains meant that traveling
that previously took days now took mere hours. Pop quiz, in 1830, the train leaves Paris
although 12:31, traveling for a thousand kilometers to Berlin. And
is it the time in Berlin? How do I know which clock is faster or slower? You see, the stun reaches high noon four minutes
later for every degree of longitude traveled towards the west. Each town had different local mean times that
were several minute office and apart. Stagecoach companies would keep the large
compendiums of local meantime differences of areas they served so they could adjust
their watches as they arrived. But with stagecoaching with so slow, it was
not a problem. You were usually only in one location per
day. With the advent of trains, things were more
complicated. So simplify and solving with the railways
came up with railway time. All across Europe and America, they operated
off of their own time. For the most part a single or a finite set
of time areas that these trains would operate in. However, railway time often had nothing to
do with the local mean town of the train station that it was located in. Meaning you would have to set your watch when
you got on the train, set it again once you got off, and once more when you entered the
train station and the town. And probably a fourth time when you entered
the courthouse for your appointment. This is the exchange in Bristol, showing two
minute times. One with local time and one showing London
time. Trains made Bristol accessible enough where
it was possible that you were doing business with London, especially using a telegraph
machine. This complexity came to a head on August 12th
in 1853. Two providence and Worcester trains collided,
killing 13 and injuring 50 in one of the biggest train accidents of the day. It’s also famous for being one of the first
photographed train wrecks in history. It was the inability to calculate the arrival
and departure would cause them to miss each other. It did not. It led credence to a growing way to look at
a singular meantime across the world. But even this was fraught with politics and
not science. England wanted their royal Observatory to
be the meridian. And France was the scientific power and wanted
Paris to be the all time. And Prussian time should be the time our clocks
should operate on. Since two thirds of charts used Greenwich
meantime in England, it was the prime meridian for the standardization of time. Now calculating Paris to Berlin was simple,
and train accidents, at least for the cause of mis scheduling, reduced significantly. So, this same applies to the same example
of me pressing a button and feeding my cats. From whom’s perspective is noon? Going based off of me, I know at noon I need
to press a button and feed the cats. If I do it tomorrow in San Diego, my cats
get the food at 3 p.m. Not the worst thing in the world, might get
a little bit peeved. Maybe one of the flowerpots gets knocked awful
the counter. However, when we’re in Italy next month on
vacation, however, that food is coming out at 6 a.m. and I’m probably not coming home
to a functional apartment and I’m very proud of my apartment. So, we realize there’s more to the date than
a simple number or even a simple position of the sun. It is insufficient to know when. We also must know where the 12 p.m. is. Okay, I know I’m four hours off of UTC in
New York City. Great. I feel really smart. It’s time to get coding on the project. First, we need to store this information a
computer readable format. We could use UNIX timestamps. But it’s not very readable or understandable
and often fraught with significant issues. Like I said, like Katie said, I used to work
with PHP. Back in the day, there were some bugs where
PHP would use the local clock instead of the UTC to get the UNIX timestamp. I grew up going away from them. And there was the ISO 8601, we had a universal
timestamp, a point in time easily digested by computers and humans and converting in
and out of universal time without necessarily knowing the context of the systems. This is why ISO 8601 was used in email. That was the originally intended purpose of
ISO 8601. The key to building a future is to attach
a UTC offset with the timestamp. This way I can send the message to a server
and say, yes, I generated this at this time. You can do with this as you please and you
can figure it out based off of what you’re doing and I don’t have to worry about where
and when you are. So, great. So, for example, tomorrow’s feeding in ISO
8601 would look a heck of a lot like this. In fact, it would look like this. Noon at minus 0400 on the 15th. Correct, yes? For now. Remember, I said earlier that time zones are
a political beast. When they were adopted, scientists originally
invented  envisioned these clean one hour time zones along longitudinal timelines. Starting at the Greenwich meantime over the
Greenwich Observatory. But time didn’t come out so clean. They didn’t follow natural longitudinal boundaries. That was too easy. In the US, they’re ragged, you can see. But they’re for the most part clean, fairly
reasonable. But it’s not simple. Start exploring the map with time zones. They migrate east and west when they shouldn’t. Argentina, they should be in minus 4, but
Argentina does whatever Argentina wants and so we deal with it the best we can. But god knows what’s happening here. Three and a half, five, six and a halftime
zone offsets. No idea what’s happening. And it continues to get worse. I’m not sure I can follow the plot anymore
with how these lines are going around. And then things just get extra special in
Australia and we’ll cover a little bit later. [ Laughter ]
Got to love the Australians. All right. I accidently forgot about that slide. And Antarctica is the worst. Look at this. Look at this and just cry. That’s what I do. But honestly, if you look at this, as much
as I like to complain about how ridiculous it is, it makes sense. Time zones exist to make sure we have standard
time. And we still orient our clocks around solar
noon. When you’re at the south pole of this planet,
there really isn’t much  the solar noon lasts months. There’s no concept of which time zone you’re
in. And as you start moving away, all of a sudden
a zenith of the sun backs reasonable. And becomes the time zone of whatever country
happens to have a research base on the continent. Okay. So, I’m  what? You know? I don’t know, 15, 16 minutes into this talk
and we haven’t started yet. So, you know what, I just don’t want to deal
with any of this and I’m just going to store this as UTC in my database, just like all
the geniuses replying to my Twitter thread said I should do. Great. 1600Z  Z being the shorthand for UTC that
I need to feed my cats. Whenever I’m in Italy, great, I know how to
convert from UTC to Italy time. I need to press the button. Done. On to the next step. Good lord. But wait. If you remember the reason we have time zones
rather than a single time is because we associate time with concepts like sun in the sky. Very hot. If we were to sit here and say, like, oh,
12 p.m. is lunch for me. But 12 p.m. for someone else is bedtime. That’s really confusing. We can’t deal with that. And in the summer months outside of equatorial
regions, summer hours are much longer than normal. Or to put it clearly, you get more daylight. And it needed to be simplified and replicated
at time. Industrialists really love making money. And the easy way to do it is if everybody
showed up exactly at the same time and ended at the same time. Your day started at the exact same meantime. If that meant half the year you woke up in
pitch black darkness and the other half home in pitch black darkness, so be it. The wealthy industrialist didn’t like it. But this man did care. He liked to go out and collect insects after
work and this whole the universe is messy and complicated thing wasn’t his jam. He put forward the modern proposal that eventually
became daylight savings time. Where in which if we changed the clocks that
if I left at 5 p.m., I could guarantee at 5 p.m. the sun was up. And he could go off and catch butterflies. Yes. All of fur problems we have ever had with
daylight savings time was caused by a dude who wanted to play with bugs after work. Daylight savings time in the US is moving
the UTC forward one hour on the second Sunday of March and reverting to the time on the
second Sunday at 2 a.m. in November. The certain time, minus 0400, and then minus
0500. If you notice, there’s a flaw in the simple
UTC solution. I was assuming 1600 UTC is always 12 p.m. That’s not always the case. During standard time, which is fall and winter
months, UTC  1600 UTC is actually 11 a.m. local time so my cats would be fed early. They’re not exactly angry about that. But as a programmer, everything needs to be
perfect and it bothers me. You see, it’s the offset that changes for
New York. If the location I’m in at the time doesn’t
change the offset, I don’t know this. And if I operate on local time, I completely
use this context of New York City. You see, UTC does not follow daylight savings
time. It stays the same. That’s why it’s a simple solution and we like
using it, but we forget a certain amount of context. But like time zones, daylight savings time
was also politically implemented and based and thus arbitrary, inconsistent and very
capricious. Here we have the United States. Notice our friend, Arizona. Not on mountain time, but not observing daylight
savings time as we see with the handy legend. Except, we see this line right here. Yes, Arizona doesn’t follow daylight savings
time, except on the Navajo reservation, then you saw it. And somebody in Salt Lake City and somebody
in Phoenix will have different clocks depending on the time of year, unless you’re in the
Navajo nation and you’re not different, or are, I don’t care anymore. It’s getting confusing. And lest you think I’m picking on the United
States, we’re not the only ones. Australia has the partial daylight savings
time. Where you have no idea what your neighbor’s
time is at any time. Unless you have a reference book. And I don’t have space. I live in New York City. And fun fact. What’s wrong with this time. Look at it. A hint, focus on the parts that are actually
important. The answer is, for those of you, some of you
may have gotten this in your head, some may not, this time does not exist unless you live
in Arizona or on the Navajo reservation. It’s the 10th of March 2019, at 2 a.m., Salt
Lake City flips over to 3:01, there is no 2:01 in Salt Lake City, but there is in Arizona. And some states had to come out and make things
a little bit more ridiculous. Which state? If you thought Florida, then you were correct. In 2018, Florida wants to change time. And unlike Arizona, they always want to be
on daylight savings time, as opposed to Arizona which is never on daylight savings time. I have some feelings about Florida. However, regardless of those feelings, I really
to want take you through this build because it’s fantastic. Look at the wording of this bill, whereas
as the sunshine state, Florida should be kept sunny year round. I have feelings about the wording of this
bill. But for those of you who wonder why didn’t
I have a panic about this a year ago, if you read tissue it turns out Florida passed this
bill, but not the ability to actually implement it. You see, the federal code says you are allowed
to opt out of DST. You are not allowed to permanently opt into
DST. This bill says one day if the federal government
lets us, we’ll be completely ridiculous. I have no idea what’s happening in Florida. But we need something more than he’s UTC offsets. We are seeing, there’s so much context loss. Idea the Iana context identifier. This was started around 1996 and created the
naming conventions that we know as programmers but maybe haven’t delve into. And it’s important to look at future historical
timestamps. I highly suggest if you haven’t, you go to
the IANA.org website, download the database and open up the news file. The change log for the database is absolutely
fantastic. Look at this, the Egyptian government changed
its mind on short notice. And decided not to introduce it after all. It’s a study into the decent into madness
of one lone citizen trying to bring order into the world. When I gave this talk, this change law was
at the top of the file. With good eyes, notice it’s now lying 1327
so there’s a lot that’s been happening since 2016. So, offsets, and instead we marked the closest
municipality that we follow their standards on. Is your timestamp America Phoenix or America
Denver? It’s very important. If you’re Denver, you’re respecting calculations. If you’re in Phoenix, it knows not to respect
daylight savings time. It’s important for a city, as well as knowing
the location of the locale. However, if you dig into the file, there’s
even more fun. If you thought Florida was crazy, I have news
for you. You can see Indiana gets its own namespace
and it shows up several times. I had no idea. I thought to myself, maybe Wikipedia can help. So. So, I looked at page. This is the time in Indiana Wikipedia page. [ Laughter ]
Some of you may be thinking what’s ridiculous about that? This is the time in Texas Wikipedia page. And this is the time in New York page. It’s literally a couple slides about how New
York decides when broadcast times are. Deep dive into Indiana. Around 1919, the standard time act made Indiana
a central time zone. Some decided to ignore this and observe eastern
time. Some daylight savings time. Off to a good start, doing whatever they want,
supposed to be central time. And then the interstate commission divided
Indiana in half, eastern and central time. Absolutely nobody in Indiana observed this. And then in the northwest and southwest, they
observed daylight savings time in the central time zone. Everybody else was in eastern time with six
counties observing daylight savings time. Are you following me? 1977, pike county stopped observing daylight
savings time. And then moving from eastern time and decided
to not observe daylight savings time. In 2006, eight counties moved from eastern
to central, and the entire state decided to observe eastern time. And then returning to east time. And in November of 2007, the southwestern
counties returned to eastern time. And then my favorite part, there are counties
in Indiana that don’t even do any Indiana time zones. Dearborn and Ohio county, New York time, Chicago,
a bunch, and America, Kentucky, Louisville. Kentucky gets its own namespace. Absolutely fantastic. So, rolling this together, we now realize
we need more contextual information than just an offset. The offset is insufficient and the way this
is happening is so critical to the function that it can’t be left out. Because really my cats, just like your users,
could care about the Indiana legislature, the whatever legislatures decided to do when,
where, what. All they care about is are they going to get
their snack at noon? That’s the only thing they care about and
your users care about. And continue on, and with everything we learned. And unfortunately, time is about up. So, did we learn anything? I think maybe we did. Probably not. I have a couple of takeaways from this talk
that I hope you walk away with. One is that we should treat time as if it
reduce complexity, and it’s political. It’s arbitrary and made up in the first place. It’s complex because we decided to make it
complex and we should probably respect that it’s always going to be complex. Time is a question of where almost as much
as it is when. While it is perfectly reasonable to capture,
say, your logs on your servers and pinpoint in a universal time, that’s perfectly fine. For what you present to your users and what
your users present to you, where the user is, where their perspective is, and where
thing the actions their taking is happen is vitally important and we should be aware of
that when we build our systems. You should treat UTC like it’s a synchronization
and conversion aid. Converting your timestamps to UTC will not
save you. Don’t treat it like that. Treat it as neutral ground. You can meet to exchange information. Always observe your presented offsets and
time zones and only convert so UTC. For those using MySQL, you convert to UTC
to do calculations. If you’re using postgres, take advantage of
the power you have to you. But more importantly, if a user gives you
a timestamp in minus 0 400, observe that. It is not going to hurt. Always use ISO 8601 and handle it in the timestamps. Give the browser and the user control. Don’t try to take over and tell them what’s
best. Let them and the tools tell them what’s best. Let the browser decide what time to see things
in. Be explicit about the context with your user,
if this talk was confusing for you, and certainly was for me. It’s worse for them. Tell them when they’re creating a timestamp. Hey, it’s 12 p.m. in eastern time, it’s 12
p.m. in San Francisco time. Tell them when and what they’re doing is,
they’re only thinking about their local time. And you will catch bugs early if you take
the extra few pixels to warn what’s happening. And use a library for simple arithmetic. I have fallen in love with date fns. There’s moment.js, there’s temporal stuff
in Node. Use a library. Even if it’s as simple as adding 3600 strokes
at a time. If the library is wrong, the library will
fix it. Time is more complicated than we give it any
sort of credit for. When all else fails, move to Florida. It’s the sunshine state and it’s going to
be sunny year round. And if you thought 
[ Applause ] And make sure, these are the  thank you very
much. [ Applause ]
KATIE: Nice one. Yeah. All right. So, I guess we all understand now why moment.js
is so freaking big. I have a bone to pick with you, I’m sorry. So, I’m from Massachusetts. Massachusetts is in America and not England. It’s Worcester. Not woo ster.>>Thank you. KATIE: You’re welcome. This is very important information. If you think the time zones around the world
is confusing, you should try to figure out how to pronounce any one town in Massachusetts. Because there are no rules. It’s like  all right. What time is it? Oh, well, we have about 15 minutes until the
last talk of the day. Hayley Denbraver is gonna be up here talking
about chaos engineering and incident management that she worked on. So, yeah. We’ll see you back here in about 15 minutes.




Leave a Reply

Your email address will not be published. Required fields are marked *