Skip to content

Preserve explicit times when parsing fractional seconds - #90

Open
x0Lazarus wants to merge 1 commit into
jinzhu:masterfrom
x0Lazarus:fix/fractional-second-detection
Open

x0Lazarus wants to merge 1 commit into
jinzhu:masterfrom
x0Lazarus:fix/fractional-second-detection

Conversation

@x0Lazarus

Copy link
Copy Markdown

Parsing a timestamp with fractional seconds can silently replace zero hours, minutes and seconds with the reference time. For example, with a reference time of 17:51:49, 2002-10-12T00:00:00.1Z becomes 2002-10-12T17:51:49.1Z. A time-only input such as 00:00:00.1 can also lose the reference month and day.

The time-detection expressions only recognize fractions with 3, 6 or 9 digits. Recognize any fractional precision accepted by the existing time parser, including its comma separator, so explicitly supplied clock components stay intact. Parsing and validation still use the existing layouts and Go's time parser.

Added 80 cases covering fractional precision, zero fractions, UTC and numeric offsets, date-and-time inputs, and time-only inputs. 62 fail before this change. The full test suite and go vet ./... pass locally on Windows with Go 1.17.13 and 1.27.1. The Ubuntu CI jobs and Go 1.16 have not been run locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant