So, if you'd insert multiple items in a single transaction, all of them would end up with the same value in the "created" column.
I recently added some indices to a few tables to speed up a complicated query with lots of subqueries and joins and ran into many unit test failures because usage of the new indices changed the order in which items with the same "created" values were returned.
> yet ignores DST
Uhm, you do know that you're supposed to use a neutral timezone (Such as UTC) internally in your code / schema, and convert to local time in the UI?
The bugs that I've hit generally have to do with using local time accidentally when UTC is expected.
> because every single developer has moved clocks back and forth twice a year for their entire lives
WTF? Every single developer knows that their database schema should be in UTC and thus immune to DST issues.
I inherited some code that was sending push notifications to users with a daily summary. I don’t remember why it was tripping over DST, since the notifications were at a “reasonable” hour (9am?) and afaik the time change happens during the hours most people are asleep, but the ruby API being used had errors for “there are zero / two times that match the time you asked for”.
I had to scratch my head for a little on why we were seeing both the zero and two errors in September / October, despite being intellectually well aware that the southern hemisphere seasons are the opposite of the northern.
Anyways, the only real solution for managing time is to use a library like Luxon so you can stop thinking about it. Time is like cryptographic encryption - Don't roll your own solution if there is a battle tested library available.
For things like, say, HN posts or whatnot storing as UTC is usually the right answer, but even here there's some nuance; for example email Date: headers tend to include the TZ of the person who sent them, and if you just store all of that as UTC you lose that information.
Or so I thought.
All calendar invites I own are set in Arizona time, so for everybody else they shift. Queue the rescheduling requests.
For the ones I don't own it actually is better for me as they all shift an hour later.
Only if you deal with timestamps that don't contain timezone information. With TIMESTAMPTZ in postgres it's transparent, you don't have to do anything specifically to manage DST.
[1] https://www.postgresql.org/docs/current/datatype-datetime.ht...
Where I live, South Africa, we have a single timezone which never has DST.
It is very easy for a developer here to be oblivious of time zones/DST as in practice it will never bite them in the local only market.
Well, I lie, it’s only almost never, a common smell of incorrect time handling is when the deployment instructions have a note to ensure the server is set to the correct time zone.
Tangental pet peeve of mine, in the early 2000s I received an abuse report with quoted logs with the timestamps being qualified as merely EST (or some other US time zone), which I found super annoying as I had to look up what the offset for such time zone was and then manually apply conversions before I could do any investigating of my own.
In Mexico DST started in 1994 so developers who started before that (hello!) did need some adjustment and operating system support was not a given.
There are also countries where DST is not observed or differs from the US yet developers from those countries might be working remotely for a US company, with US developers or needing to accommodate a significant US clientele.
The operating system keeps track of every locale's DST dates, all the way as long as DST has been a thing. When governments change the date, via law changes, the change usually gets passed along in an OS update.
https://en.m.wikipedia.org/wiki/Daylight_saving_time_by_coun...
Consider a page with 10 rows, and in each row you show the relative date.
2 issues with that:
1) If I see a whole page and I see 1 week ago the range is 7 days. If I see 1 year ago the range is 365 days. That is too much for most of the things. 2) If I am on a page without visual indication of sort order and I'm on a page that shows 10 entries with '1 year ago' I have no clue about the sort order.
I hate relative dates.
Still, "1 year, 7 months, 2 days, 5 hours, 3 minutes ago" isn't always ideal either, not even when it's done in a lexically sortable way.
Ultimately it boils down to a choice which doesn't match problem the user has, and in different circumstances someone might want relative or absolute.
Then the user doesn't have to mentally cross-convert between relative measures and absolute timestamps, which is less error-prone and annoying.
One day, I fixed an issue in the message producer that was causing the routine to take unreasonable amount of time and resources so that latency went from 1s to ~50ms.
Three hours later P1 is raised and the entire architecture had to be refactored. I still have the screenshot of the latency graph saved somewhere :)
create an index on both the pubdate (timestamptz column with potential duplicates like your post mentions) and a uuid primary key column (id in my case) problem solved
1. If the clock moves backwards (and an "older" record gets created), it doesn't help.
2. If a duplicate timestamp is created with an id that sorts earlier than one of the other dups (and a user has already synced to the first dup).
In both of those cases, the user won't receive the new record. (Yes, neither is probable, but neither is impossible.)