temporal icon indicating copy to clipboard operation
temporal copied to clipboard

ZonedDateTime methods should be infallible

Open Manishearth opened this issue 7 months ago • 4 comments

ZonedDateTime has a lot of the same methods as PlainDateTime, like .year(), but they're all fallible because of the provider stuff.

With compiled_data they should definitely not be fallible. We should also consider having these never be fallible, and having the case of "mixing providers" be treated as pure GIGO.

Manishearth avatar Jun 03 '25 00:06 Manishearth

I realized that the constructor does not check the timezone, even though the spec does. Boa does this validation externally, which I guess we can do in v8 as well. But in that case perhaps we should have a separated ValidatedTimeZone type?

Manishearth avatar Jun 03 '25 01:06 Manishearth

I realized that the constructor does not check the timezone, even though the spec does.

The constructor checking the time zone currently is something I'd like to do, but would require baked data. See #306.

nekevss avatar Jun 03 '25 02:06 nekevss

See also: https://github.com/boa-dev/temporal/issues/330#issuecomment-2933160973 for a potential principled approach here.

Manishearth avatar Jun 03 '25 02:06 Manishearth

FWIW, I've since moderated my position here: I think it's okay to have these fallible and only ever returning assertion errors.

Having these be infallible-but-GIGO is a potential option, still, but I'm more wary about it: our normalization data and our tzif data do not have the same source; which means they can get out of sync.

Manishearth avatar Aug 01 '25 03:08 Manishearth