-
Notifications
You must be signed in to change notification settings - Fork 0
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
Timestamp representation/validation #12
Comments
Agree. Time is weird and hard and Ion is a data format, so ideally we just surface correct data and let the user figure it out.
This matches my experience.
I think we could support this with crate features for
Probably not, given the non-overlapping behavior between
Very much agree.
I think the best bet is probably to check as much as we can.
Since fractional seconds can't cause the
I believe this is not an issue. Notably, Ion doesn't support moments in time prior to Jan 01, 0001, so we don't have to worry about the negative side of things. Also, by construction from these two clauses we can deduce that Ion doesn't support years past 9999.
|
This is actually the first time I puzzled through the valid |
Yeah, that seems reasonable.
I agree on checking as much as we can. As far as internal representation goes, we'll have to create the Do we want to pare the representation sizes down to what can be represented within the timestamp spec/what Also, how did you feel about the more hierarchical type structure ( |
SGTM
Agreed.
Yes, a lot of things get simpler now that I know from reading the text specification that years are bounded in the range (1, 9999). The
I don't think that the variants of |
Cool, I've added an issue: #14.
Apologies for being unclear, I meant as a contrast to the flat layout of |
I prefer the flat layout for |
Issues around timestamp representation cropped up again recently. |
Hiya.
We'll need to figure out how to deal with Ion timestamps. Here's the simple definition of an Ion timestamp from the spec:
Arbitrary precision is the interesting part. A valid Ion timestamp can be a year (e.g.
2007T
), at minimum precision. There is no maximum precision for fractional seconds.The set of requirements look something like this:
Goals
Ideally, we get out of the way when dealing with timestamps. Also ideally, people tend to use certain ISO 8601 serializations (that is, I would suggest that second and millisecond are probably the most common precisions, though I don't have data to back this up).
I would like to provide a clean way for clients of the library to extricate timestamps to their favorite crate. However, this is a non-trivial problem as no crate currently provides arbitrary precision timestamps so the behavior for how this should be done is largely up for debate.
A non-goal is fully integrating a date/time library (though it could be?).
Approach
It feels beyond the scope of this library to implement a fully functioning arbitrary precision timestamp toolkit, so I think we should try to pick a crate that can do most of the heavy lifting for us if possible. Unfortunately, a crate for that use case doesn't exist yet. We can extract parts that are useful (such as the Date and UTC offset in #11).
We could go further and use the Time and DateTime types internally, however this is where arbitrary precision begins to rear its ugly head. It might be possible to work around this where precisions match types available in libraries, but the question is what do we do when they don't? A trait might be a good solution here, allowing the client to define the binding to the timestamp library.
Date and Time Crates
After a brief survey of the date and time crates, there are only a couple of options:
Both seem to be maintained and frequently used. Chrono is a superset of time (i.e. it depends on time and adds an extended API as well as some other features). Chrono also includes a list of limitations.
The chief limitation seems to be arbitrary precision fractional seconds. Another potential limitation, depending on if the requirements are for a four digit year or an arbitrary precision year, is the +-262,000 year limitation. I'm not sure that this matters if we are only using the library for validation and internal storage of a UTC offset.
That's probably enough thoughts on timestamps for now.
The text was updated successfully, but these errors were encountered: