More correctly document %NS and invalid coarse parsing behavior
#231
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #230
It turns out this was not actually a date bug. I misunderstood how
%NSwas supposed to work. Really this is only useful for cases where you need to parse seconds that might have more than one leading zero, like007. It should be extremely rare to ever useN. I have completely redocumented how that is supposed to work.date considers parsing a string with fractional seconds into a coarser time point, like one with second precision, to be unsupported behavior (a similar argument is made when parsing a string with hours into a day precision time point). I was unaware of this, and thought that
%NSwas used for this exact case, which is not true. Instead you should use a precision that is at least as precise as the string you are parsing. So a string with milliseconds should be parsed as millisecond, microsecond or nanosecond precision.This impacts the way the Date and POSIXct parsers work. Because we treat POSIXct as second precision, it is no longer considered correct behavior to ever parse a string with fractional seconds using
date_time_parse(). Instead, you should parse into a naive-time that can handle fractional seconds, round, then convert to POSIXct (this is shown in multiple help files, and the NEWS bullet).