-
-
Notifications
You must be signed in to change notification settings - Fork 26
Implement timestamp unit infer for other types #94
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -439,7 +439,8 @@ impl DateTime { | |
| timestamp_microsecond: u32, | ||
| config: &DateTimeConfig, | ||
| ) -> Result<Self, ParseError> { | ||
| let (mut second, extra_microsecond) = timestamp_to_seconds_micros(timestamp, config.timestamp_unit)?; | ||
| let (mut second, extra_microsecond) = | ||
| timestamp_to_seconds_micros(timestamp, config.timestamp_unit, MS_WATERSHED)?; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ..If you expand below, you'll see that we call
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could have |
||
| let mut total_microsecond = timestamp_microsecond | ||
| .checked_add(extra_microsecond) | ||
| .ok_or(ParseError::TimeTooLarge)?; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass also if I use the default (which will use
TimestampUnit::Infer), but I'm trying to be extra safe here and make the config match the existing default behavior (see below).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, the time config attribute of the datetime config should only allow
TimestampUnit::second..There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just remove
timestamp_unitfromDateTimeConfigso that it's not possible for there to be inconsistency? Would be breaking, but I think not too bad for users to adapt to.InferandSecondare presumably equivalent forTimeparsing, because the watershed is far out of range of a valid 24 hours.