-
Notifications
You must be signed in to change notification settings - Fork 859
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
Are LocalDate, LocalTime, LocalDateTime and DateTime different types? #596
Comments
Also, why are they called Local* when their interpretation is actually undefined? Doesn't Naive* make more sense? |
Good question! My first take was that, for the sake of making arrays heterogenous, all Datetime subtypes are the same. (Historically, there was only one Datetime type in TOML.) Changing all the subtypes into distinct types makes sense to me. But my reasoning has more to do with type translations between TOML and programming languages, and less to do with preserving homogeneity in arrays. |
I'd say it's pretty obvious that they are different types (and hence cannot be mixed in arrays), since they are listed as different types in the spec. If Offset Date-Time and Local Date-Time are mixed in an array that's probably a mistake – either one should be used consistently. The only potential use case I see where mixing date types might be useful is a combination of Local Date-Time and Local Date with an (app-specific) convention such as "Local Date represents that day at (local) midnight" – or possibly Offset Date-Time and Local Date-Time with "Local Date represents that day at UTC midnight". But that's all a bit fuzzy and probably better avoided. From a user's viewpoint, it would be more useful if Integers and Floats could be mixed (with ints optionally autoconverted to floats by parsers in strongly typed languages), so that series such as |
@ChristianSi you're right, it looks like most parsers already treat the date types as separate types, and the spec does, too. |
Closing this issue because "it's pretty obvious that they are different types". Thanks @ChristianSi. |
Just curious, @quadrupleslap: do you have a real-life requirement of homogenous arrays of date/time values? Asking because of discussion surrounding arrays recently. |
toml-rs treats them as the same type (for the purpose of forbidding heterogeneous arrays), but that doesn't sound like the correct behavior.
The text was updated successfully, but these errors were encountered: