Add ZoneNameTimestamp::from_epoch_seconds#7720
Add ZoneNameTimestamp::from_epoch_seconds#7720robertbastian merged 2 commits intounicode-org:mainfrom
ZoneNameTimestamp::from_epoch_seconds#7720Conversation
ed4cce0 to
73f491b
Compare
73f491b to
30732f3
Compare
Manishearth
left a comment
There was a problem hiding this comment.
yeah that does look cleaner
sffc
left a comment
There was a problem hiding this comment.
Issue: This makes the tests and docs significantly less readable.
I'm in favor of adding the constructor but not using it as a replacement for the ISO calendar dates in tests and docs.
|
it makes them significantly more realistic you proposed this method |
|
I've responded to your comment |
I'm trying to find a compromise here. You didn't like using non-ISO calendars, so this is the compromise, and it's actually the best solution. There are four ways to document
|
|
A fifth option is .with_zone_name_timestamp(
ZoneNameTimestamp::from_epoch_seconds(
ZonedDateTime::try_from_str("2026-03-04T12:00Z", Iso).unwrap().to_epoch_seconds()))and a sixth .with_zone_name_timestamp(zone_name_timestamp!("2026-03-04T12:00Z")) // or something similarA seventh would be to use a third-party library to get the timestamp if you find ZonedDateTime untasteful to use. |
|
We don't currently have |
|
And re the macro, I'll point out the same thing I pointed out when you wanted to add a |
|
|
|
It's not just that |
|
I also think it's bad to put actual dates, because that can be understood as if the date is used to determine whether a timezone formats as "standard" or "daylight", which is not the case. We currently set winter dates for winter timezones, and summer date for summer timezones. This doesn't happen with an opaque timestamp. |
|
Then add |
|
What does that solve? |
That doesn't really make a lot of sense either, though. You are allowed to use a winter ZoneNameTimestamp to display a time in the summer. |
|
The way I see these examples it that they are primarily for libraries to integrate with |
sffc
left a comment
There was a problem hiding this comment.
I don't agree with your choices on documentation but you explained your perspective and they seem like something a reasonable person could arrive at.
The current API requires constructing a
ZonedDateTimefrom UNIX seconds, and then internally converts it back to UNIX seconds.Split from #7630
Changelog
icu_time: Add
ZoneNameTimestamp::from_epoch_seconds()ZoneNameTimestamp::from_epoch_seconds()