-
-
Notifications
You must be signed in to change notification settings - Fork 301
time::Time precision #729
Copy link
Copy link
Open
Labels
A-coreArea: anything not otherwise coveredArea: anything not otherwise coveredC-blockedCategory: blocked by another (possibly upstream) issueCategory: blocked by another (possibly upstream) issueC-feature-requestCategory: a new feature (not already implemented)Category: a new feature (not already implemented)
Description
Metadata
Metadata
Assignees
Labels
A-coreArea: anything not otherwise coveredArea: anything not otherwise coveredC-blockedCategory: blocked by another (possibly upstream) issueCategory: blocked by another (possibly upstream) issueC-feature-requestCategory: a new feature (not already implemented)Category: a new feature (not already implemented)
Fields
Give feedbackNo fields configured for issues without a type.
It is often needs to relax time precision requirements. Suppose we need to design the train tickets selling system. So we need the ticket representation in our program. Every ticket has a departure time and an arriving time and we want show it in our representation. Usually, trains schedule builds with minute precision (without seconds or nanoseconds), so we want to store the minutes and hours of departure and arriving. And, as trains may travel long distances, we want to store the date and time with utc offset. Summarizing,
time::OffsetDateTimeis most suitable type for us. And here we got into trouble. If we want to be able to compare departure or arriving times, we must keep invariant that nanoseconds (and seconds) will always be zero. And the library will not help us. It is all on us. Also we have to store at least 5 extra unused bytes for each time instance in our program.I suggest to provide different
Timetypes for each one precision quality and add suitable cross-operations between them. I would like to discuss the exact design, but for further reading suppose we have typeTimewith generic parameter precision.