18

The primary application at my job was...not well written. Originally .NET Framework 3.5 with a strange collection of approaches to MVC. SQL Server for data. I claimed it look like something written by CS students fresh out of college on their first job. Turned out I was close...it was written by 3rd-year CS interns. We've fixed and improved a ton (including migrating to .NET 6 earlier this year).

One of the ongoing issues was the use of SMALLDATETIME and DATE fields for everything. We've been gradually migrating these to DATETIME2 or DATETIMEOFFSET (we don't have future dates) as UTC. Because 95% of our usage had been CST/EST, we've typically set the time component to 17 hours to get a reasonable noonish time in those zones when we don't have a better time of day.

Had another round of these today and thought it was going well. Finally got it running and everything was +1 day from where it should be. Spent an hour trying to figure out the issue.

Converting for display incorrectly? No. Serializer not doing what was expected? No. Configured time zone got messed up? No. Brought in our DBA to help me figure it out.

I had added 17 days twice.

Side note: I wish everybody was on UTC time and time zones would forever disappear into the ether.

TLDR; Migrated time wrong because I'm stupid.

top 11 comments
sorted by: hot top controversial new old
[-] beejjorgensen 5 points 1 year ago

One front-end project I did connected to a backend API that had the "time of product launch" stored in local time on the server, which was eastern time. I was to display a "time remaining countdown" on the web page.

At the time, JS wasn't great at doing anything other than localtime and UTC. (Not sure it's any better now.)

The DB folks were unwilling to change the date from the backend to UTC.

Great. I'll just math it over from eastern to UTC on the client, then convert to local.

Of course, the countdown to product launch spanned a shift to daylight saving time. Great. I'll just add some condition and change the offset on that date.

Tested it like crazy, and it seemed to work.

A couple weeks later with 2 days to launch, the countdown was suddenly off by 2 hours (??!) and I had to sort it out.

Turns out they'd switched over from their dev API server on the east coast to their production API server in mountain time.

Changing one constant in my code fixed everything, but I swore I never wanted to have a universally single event stored in anything but UTC ever again.

[-] OsrsNeedsF2P@lemmy.ml 3 points 1 year ago

Side note: I wish everybody was on UTC time and time zones would forever disappear into the ether.

Everyone who has worked with dates feels this way. I for one have switched to the 24:00 clock and keep the UTC time as a widget on my phone. It won't happen in our lifetime, but I'll be damned if I'm not stubborn about it.

(Also as a side note, I work in game dev and I force everything to be in UTC. I don't care what the PM says, our events all reset midnight UTC)

[-] vraylle@beehaw.org 1 points 1 year ago

I've been on military time since doing a lot military contracting.

[-] Dathknight@feddit.de 3 points 1 year ago

I feel you...

One of my services connects multiple systems. Some with timezone information some without. It is all a big guessing game ... Add some misconfigurations of VMs and you get some very interesting errors.

[-] beardcrumbs@beehaw.org 3 points 1 year ago

After having tests work on my computer but mysteriously fail on test server I discovered that test server was set to UTC and tests that depended on having test data return the same time/date failed. Since it was not critical to test those edge cases we just offset times in test cases so that they didn't overflow into next day in our test server. It never gets boring when working with time and date.

[-] CHollman82@lemmy.world 3 points 1 year ago

I hate everything having to do with times, dates, and languages. It's like we are used to rigor and logic and human invented systems from millennia ago are anything but...

[-] Penguincoder@beehaw.org 2 points 1 year ago* (last edited 1 year ago)

Timezone programming sucks. The philosophy I got by is, to store/track/log everything in UTC. When it is displayed, then change the format to the local user timezone IF NEEDED. For example if it's like network device logs or security events, one timezone (UTC normally) should be used, not changed for every user. Convert the reverse for input from client, to back end.

[-] anji@lemmy.anji.nl 1 points 1 year ago
[-] knighthawk0811@lemmy.one 1 points 1 year ago

Tom Scott has entered the chat

[-] dolle@feddit.dk 1 points 1 year ago

Why are you migrating from DATE to DATETIME2? If the original data didn't need a time component then I don't see why you should add one.

[-] vraylle@beehaw.org 3 points 1 year ago

Because it originally didn't account for time zones at all....it was very "everybody is in Virginia". The day was even wrong for many countries. When a training program shifted to include other countries it suddenly mattered. And it correlated to other data that did have times.

this post was submitted on 07 Jun 2023
18 points (100.0% liked)

Programming

13360 readers
9 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS