r/ProgrammerHumor • • May 17 '21

Timezone Support

Post image
22.3k Upvotes

460 comments sorted by

View all comments

Show parent comments

32

u/TabularConferta May 17 '21

I was curious about this so I checked. The length of a day on Mars is 37 minutes longer than Earth.
This does raise interesting questions as to how we use time.

The easiest solution while we remain in the solar system is to keep all time UTC and Earth based. People may choose to live their days my a localised time, but they would still use Earth based as standard.
This would enable a "Universal" system which is compatable with current standards.

People perception of day night and sleep cycles I think it what may determine how people live their lives on Mars and part of this comes down to what form of habits we live in. If we live shift work on Mars, then maintaining Earth time makes sense. If we manage to start growing plant life and need to actually case about where the sun is (rather than using artificial light) then this would lead towards requiring MST (Mars Standard Time). Ultimately it comes down to future humanities use case, but for the foreseeable future, I would reckon UTC will be sufficient.

37

u/[deleted] May 17 '21

More on time stuff, as I'm reading about it for a project. Also disclaimer, I'm no expert, this is just what I've gathered so far.

UTC as we know it is actually derived from TAI, or International Atomic Time (acronym from French translation). International Atomic Time is actually the weighted average of 400 atomic clocks in ~50 labs around the world.

Here's the kicker, atomic clocks are goddamned accurate that the irregular rotation of the Earth is slowly making 'solar time' out of sync with our atomic time. To compensate, staring in 1972, the BIH, or International Time Bureau (thx again French) used to declare leap seconds. This has since been passed to the IERS, or International Earth Rotation and Reference Systems Service. Basically, a rough 6 month notice is given for everyone on UTC to roll their clocks forward or backward a second. So far, they have all been forward, but either is technically possible.

As of writing in May 2021, TAI and UTC are out of sync by 37 seconds.

Rolling over a second at the end of the day has proven to be disruptive in time sensitive applications, though. Some companies, like Google, have a system for adding a 10th of a second incrementally throughout the day of a leap second event to be less disruptive, but it's a problem nonetheless.

Also, there's the issue with UTC being a signed 32 bit integer that will definitely roll over and break shit in 2038 if we don't ALL update our systems to prepare for it, and I'm really confident we'll take care of that without a hitch. Y2k38, here we come. But even then, we'll just move to a 64 bit signed integer, so we're just kicking the can down the road.

That's why I, the 23 year old headass UI developer, recommend going with a 256 bit unsigned integer based on International Atomic Time and scrapping timezones for our timestamps. This both buys us enough seconds to outlast the projected heat-death of the universe, and makes JavaScript developers without a favorite BigNumber library shit themselves in anticipation of such an event. 🙂

17

u/othilious May 17 '21

With regards to UTC being stored in a 32 bit integer; that hasn't been the default in most languages for a long time.

Common databases like MySQL support 64-bit integers and have done so for a long time. Even if your column datatype is defined to be too small, a simple ALTER statement will fix that easily enough.

Modern editions of C++ and modern languages like C# or even things like PHP will also not have any issue with 64-bit timestamps, provided you actually run them as 64-bit applications.

I've worked with a few applications in an in-house ecosystem written in the above languages. One of the requirements we tested against was exactly this issue to an extreme; arbitrary storage of scientific data with timestamps in milliseconds with a floating point precision of 5 decimals. Turns out; not actually that hard if you've kept your environments up-to-date and run 6- bit, which is pretty much everything these days.

So the Y2k38 problem has already been solved today, so if it bites you in the ass ~17 years from now, you don't have anyone to blame but yourself. Or management. Probably management.

1

u/[deleted] May 18 '21

Nice, thank you for this!

1

u/thblckjkr May 18 '21

a simple ALTER statement will fix that easily enough

Doesn't the alter statement need an incredible amount of processing power and I/O bandwidth? If I remember correctly, the majority of the relational databases are designed to store data in a linear way (since reading/writing in a disc was a linear task), so, to change the size of a column you basically need to rewrite the entirety of the data, taking record by record, altering them in memory (adding left padding bits), and storing the new state.

That messes with critical transactional databases, and needs days of downtime in databases with >1M records. So... certainly an easy task, but not a easy one to convince management to solve.

2

u/othilious May 18 '21

It depends on your database and your setup, but if alter statements are impossible to run on your environment due to the size, you have bigger problems.

In this scenario the developers/admins/management are left with a choice; either schedule a downtime maintenance window for the time needed to make the changes, or face an outage for an indeterminate length + the time needed to run the alter statement when it breaks. And that's not including the time needed to clean up the mess caused by your system doing weird things due to something basic like your clock not behaving.

9

u/Sese_Mueller May 17 '21

Wait until you hear about the fact that it is impossible to know how many minutes and seconds earth and mars clocks would be out of sync (i.e. earth might be out of sync with mars more than mars with the earth) since light speed can only be measured two ways.

→ More replies (5)

1

u/BIG_BUTT_SLUT_69420 Jun 12 '21

Basically, a rough 6 month notice is given for everyone on UTC to roll their clocks forward or backward a second. So far, they have all been forward, but either is technically possible.

what!

9

u/[deleted] May 17 '21

The solar day is actually 39mins 35seconds longer than on earth.

The value you have seen is the sidereal day, which doesn't account for the apparent movement of the sun over the course of a solar day as the planet moves around its Orbit.

13

u/jua2ja May 17 '21

I think it's a horrible idea to use UTC in mars. Since it takes 3-22 minutes to transmit any message to mars, I think mars civilization would pretty quickly find themselves fairly independent from earth, at least on everything except purchase of resources and trade. As a result people will have their own time system which will likely rely on the sun. I think it is possible for humans to get used to a 24 hour and 37 minute day in terms of sleep schedule, so they will shift to that schedule on mars, and they'll like want their own computers, which they would prefer working with their own schedule. I think that the most practical solution is to have a completely separate time system for mars, and for developers to just support the interactions there, including accounting for factors such as the different distances between mars to earth. Most mars-earth communication will likely be just large uploads and emails anyway, as there aren't any other practical ways to talk to anyone on mars.

9

u/[deleted] May 17 '21

I'm not trying to berate you, just point out something.

Technically a it would be a 24hr 39min 35sec day because the time you and another commenter posted was the sidereal day - which is the time for one complete rotation irrespective of the sun.

A solar day accounts for the movement around the orbit over the period and requires a few extra degrees of rotation to get back to solar noon.

With regards to a separate time system - the second will remain the same.

Unfortunately 86,400s doesn't go into 88,775s very well.

You'd have to come up with some new minute and hour counterpart for it to work.

53 seconds to a Martian minute.

67 marMin to a Martian Hour.

(or the other way round)

25 marHr to a Martian Day.

That's the best I can come up with.

4

u/MacrosInHisSleep May 18 '21

Would it work to define a Martian day as 24h,39m,35s?

Basically have the clocks go to 00:00:00 at 24h,39m,36s.

At least that way, day to day units of time can be consistent, which I think is very important.

We could even define it as 24:40 and remove an hour every ~120 days if we wanted to have less rounding and more frustrated programmers.

Days to a month can be anything really doesn't have to be 12. We can't use their moon for months, because the two moons orbit mars ridiculously faster than our moon (30 hours and 8 hours). If we did want 12 months in a Martian year, then a month would 669 martian days/ 12 = 55.75, meaning 8 months of 56 days and 4 months of 55 days.

I would name the months something different to be less confusing. I would be disappointed if the name of the third month isn't Earch.

2

u/TabularConferta May 18 '21

I think this would likely be the simplest solution. Interesting point about the calendar, I hadn't really considered that. Moving to a base 10 calendar would be nice ^_^

→ More replies (2)

3

u/ohkendruid May 17 '21

Time zones could go away on Mars and basically never be missed. We could do the same.on Earth.

Daily time would still be important on Mars, though, if anyone lived there. For local inhabitants, there will be things that happen every day, and it will he important to be able to describe the time it happens.

Hours are not needed for daily time. Seconds and kiloseconds work out pretty well. IIRC, a kilo second is about 16 minutes, and there are about 86 kilo seconds in an earth day. That's no more or less convenient than hours. Note that with hours, people are forever talking about quarter hours anyway. We may as well use that as the more fundamental unit.

Months are not important on Mars. Use weeks or days, depending on the purpose.

Weekdays also seem valuable on Mars. People organize regular events according to a weekly calendar, and they need a way to say things like the bridge game is on Tuesdays at 11:00.

Years seem valuable for discussing holidays and for generally keeping the numbers small. These are probably okay to drift from the astronomical year so long as it's no more than a day a year. It's probably just as convenient in net, though, to have years start midday, at the exact fraction of a day that the astronomical year ends.

1

u/Kered13 May 18 '21

The world without timezones would be much more confusing than the world with timezones. Questions like, "What times are businesses typically open in Japan?" and "When should I schedule a meeting between the US and Europe?" become much more complicated.

→ More replies (9)

2

u/phire May 18 '21

NASA already have to deal with "Mars Time" for their rovers, as they mostly operate during the local daylight.

At times (especially around a new rover landing) they actually shift their mission control teams from local time to "Mars Time" for a few months. Source.

1

u/TabularConferta May 18 '21

Sweet. Thank you.

2

u/Kered13 May 18 '21 edited May 18 '21

The Unix epoch would continue to be used as the "universal" measure of time. However Mars would have it's own local clock, probably using at least partly local units like Mars hours and Mars minutes, as well as it's own local calendar.

This isn't as weird as it sounds at first. We're already used to converting between time zones and between 12 hour and 24 hour clocks. Many date-time libraries can also handle non-Gregorian calendars as well (such as Hebrew and Islamic calendars).

1

u/TabularConferta May 18 '21

So the interesting thing is the Mars Clock would likely just have the extra time on it. A second is set based on caesium (I believe). So either they would have to make other new units of time or set the maximum to something other than 24hrs.

2

u/thblckjkr May 18 '21

I'm pretty sure this was in somewhat way solved on the Assimov's books, specifically in the foundation trilogy.

If I remember correctly, there was a universal time that was based on "forgotten knowledge" (earth time), but every solar system/planet had it's own time and timezone.

The interesting bit is how TF is going the relativity affect clocks, and how we are going to program it. I would think that the easiest way is to keep a "standard" clock in the earth, but if there is any anomaly in the spacetime continuum in the earth, or even if there is some disturbance at sending the data, we wouldn't have a reliable way to know. Even if we transmitted everything with light, we are just assuming it has a constant velocity, but we don't actually know... I think, i don't actually know alot of relativity and I'm just making guesses.

So, I think the solution would be to just keep an earth clock and a sepparate one for every planet, and use relative timestamps to the local clocks, not to the other planet.

1

u/TabularConferta May 18 '21

Asimov really put in the work.

That's actually an interesting point. For intra-solar travel you don't have to worry about setting the clock, its easy enough to get a heart beat from earth to check the time.
Troubles begin when/if you break light speed. Then your clocks become immediately out of sync. You can likely calculate the difference to second precision but I wouldn't trust it much further than that.

1

u/mfb- May 18 '21

The teams controlling the Mars rovers are already using sols (Mars days). And they are here on Earth. It's easy to adapt to a slightly longer day, so I would expect people to do that. Mission control can keep using sols just like they do for rovers now.

1

u/non-troll_account May 29 '21

Wikipedia tells me that it is exactly 39 minutes, and 35.244 seconds longer than an earth day.

Are they going to redefine second, minute, hour, so that mars has 24 hours? or even just an integer number of seconds?

1

u/TabularConferta May 29 '21

To be fair the Earth doesn't rotate in exactly 24 hours. A second it now defined based on atomic vibrations.

→ More replies (2)