-
Notifications
You must be signed in to change notification settings - Fork 862
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
Allow less specific datetimes. #297
Conversation
So the following is valid? 1979-05-27T00:32:00. How about dates before epoch? Or before the year zero? This also introduces the concept of a parse warning... Before it would be valid or invalid, after this it may become valid+warning. Everyone app that uses the TOML format should now decide if/how it wants to deal with warnings (tell the user? log it somewhere?). Please consider that date/time/timezones/timestamps is a can of worms that we do not want to open upon a minimal config format. Quick proof: http://en.wikipedia.org/wiki/Leap_second More proof in this blog post and sequel, most of the falsehoods mentioned are not worth considering in the context of a serialization format, some of them certainly are. |
Looks good to me 👍 @cies As for your questions, it's best to consult RFC 3339. For examples, leap seconds are addressed by the RFC (seconds in the grammar range from 0 to 60 because of that). Warnings are optional ("if possible") so I don't see that as a big issue. |
I think this would work quite well. One of the odd behaviors today is the very strict format. I think this would be a real boost to adoption. I can see the no offset being commonly used. It would definitely work well for Hugo's current use case. |
I'm merging this right now, as I think it will make TOML more pragmatically useful, but I'd enjoy a discussion about whether the bit about warnings should be changed to just be an error. |
Allow less specific datetimes.
Thanks @mojombo . I'm happy to pass along any feedback I hear about it. |
Looks good 👍 I'm in favor of leaving the warning as is, it feels like an awful waste lo let a parser die just because it has to crop 12.345678 secs to 12.345 (or 12.346) secs. Warnings might also be appropriate in other situations, e.g. when a key occurs twice in a table. The spec says "Doing so is invalid" -- leaving it up to the implementor whether to throw a parsing error or emit a warning, I guess. |
On second thought, maybe change
to
? Rounding 12.345678 secs to 12 secs would feel a bit rogue to me. If millisecond precision is the common minimum, then I think it would be OK to make the warning optional ("may" instead of "should"). |
- integrated less specific datetime TOML grammar from toml-lang/toml#297 - configure date local offset for TOML date values omitting the offset using the :date-local-offset parameter in from-toml, or by instantiating Actions with :date_local_offset parameter defined - the default is to use the host machine's local offset for TOML date values omitting the offset
It's quite dangerous to treat raw days as is suggested. For example in Brazil on the 18th of October, there is no 00:00:00 time at all, as with daylight savings it skips straight to 1 am (this gem has caused, for example, popular issue trackers to not allow issues to be defined on this day). One can have a raw days implementation, but it is very different to a day's midnight in a timezone (it's a completely different datatype). ISO 8601 also allows this (but is not what you're implementing anymore). This change makes TOML not precise, which is bad:tm:. |
I think warnings opens up a bit of a can of worms too; could one, for instance, turn on -Wall and fail? |
@HuwCampbell That's fair, but I still think this change is needed. How about suggesting noon as the time-point for raw days? Every day, regardless of daylight savings or other leap-changes has a noon. |
@ChristianSi I like this idea, it's consistent with the float spec (some minimum precision is expected), and just leave out the warning suggestion. Any implementation is free to warn on any number of cases that may cause issues for it. I'll work up a PR. |
@ChristianSi See #360 for the change regarding milliseconds. |
@HuwCampbell See #361 for the noon-time change. |
This allows three kinds of datetimes:
See #263 for why this is being proposed.