-
-
Notifications
You must be signed in to change notification settings - Fork 892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: What is the motivation for using ISO strings instead of UTC epoch/unix Timestamps #4670
Comments
We use Serde does support serializing those as unix millis or micro timestamps using |
Yeah it's big change, but other then the initial hurdle I don't see any drawbacks. Would love some more opinions though. |
I assume this is about Lemmy's API only? The obvious drawback is human readability, but this only really impacts developers. |
Yes only about the API.
If looking at raw JSON response sure, but takes only few seconds to find out. If using a "lemmy-api-client" their toString implementation can easily handle it.
I don't think there is any client out there that displays it as such. It is not very user friendly. While clients now have to do special work to parse this ISO date. But every stdlib has support for unix timestamp. Other then displaying timestamps, the most common other use case is to compare them with other timestamps. Unix timestamps can be compared directly and do not need to be even interpreted. Making it much easier and efficient. If we were to change, I would recommend millis. |
I think unix timestamps are better, but I'm not sure whether or not the mess of a breaking change is worth it |
Could do it with v4 API |
Unix timestamps dont include timezone, so this would risk reintroducing the problem which was fixed by #3496. Also API responses can be gzipped, then there should be no significant size difference. And ISO timestamps are very widely supported. |
Postgresql "timestamp with time zone" is actually just a UTC timestamp https://www.postgresql.org/docs/current/datatype-datetime.html |
No, it won't. Unix timestamp is in UTC. The problem with naiveDateTime is that you returned their local time but without the timezone information. While Unix timestamp would return the time in UTC.
Gzip isn't magic, Bigger input will still result in a bigger output. I just find it silly to use a format that is less supported and less efficient in every factor. |
Using chrono/serde ts_microseconds would be an exact fit. I'm also wondering about potential serialization issues with other federated services tho. |
I would recommend millis over micros. Much more popular (in my experience) This is only about the Lemmy API. I don't know about the requirements of Apub spec, |
Too much effort for very little benefit. |
If someone wanted to take this on, I wouldn't be opposed to re-opening and assigning it to them. But ya I agree, it's a lot of a effort and a major breaking change. |
Question
What is the motivation for using ISO strings instead of UTC epoch Timestamp?
String vs 64 bit integer
"2024-04-27T03:53:51.930329Z" vs 1714190031930
Benefits unix timestamp:
The text was updated successfully, but these errors were encountered: