gleam-lang / hexpm

🪄 Decoders for the Hex API
1 stars 1 forks source link

`updated_at` and `created_at` are not UTC-based #2

Open ghivert opened 4 months ago

ghivert commented 4 months ago

Hi!

I'm using this package, and updated_at and created_at are correctly converted in birl.Time, but they are not turned into UTC. Is it on purpose? I find it always simpler to manipulate every timestamp in UTC in backend, and manage the timezones when user interaction is needed (sending a notification, displaying the time, etc.)

lpil commented 4 months ago

We use whichever time zone Hex chooses to use and do not add any conversions.

ghivert commented 4 months ago

OK, clear, thanks. Seems perfectly rational ha ha

lpil commented 4 months ago

We could pass through the timestamp strings and not use birl? Perhaps that would be clearer.

ghivert commented 4 months ago

I'm not sure. I think the problem also comes from birl for being unclear.

The underlying problem is that I have an UTC time, while the time from Hex is without any timezone info. So I end up with Time(timestamp, None, Some("UTC"), None) while the package gives me Time(timestamp, None, None, None). This doesn't seems bad, but when doing birl.compare(a, b), it does not take into account the timezone, and just compares the millis without conversion. But I'm still unsure about the desired behaviour we want for datetime in general. I mean, if I'm in Paris at 16:00, and someone is in London at 15:00, it's the exact same timestamp, yet it's later in Paris than in London. 🤔

Maybe it's worth a discussion in birl?

lpil commented 4 months ago

Sounds like a birl bug if they're not taking timezones into account. I'd be happy to either keep this library as-is, or remove the birl usage.

ghivert commented 4 months ago

I'll open a discussion on burl to see if we can find a best solution. As of now, let's not change it. Actually I like the idea of not having to deal with datetime parsing and getting a birl Time directly.