Skip to content

Commit

Permalink
Allow parsing of decimal precision iso8601 formats
Browse files Browse the repository at this point in the history
  • Loading branch information
skmcgrail committed Aug 17, 2020
1 parent 27ae184 commit 9a0ad8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion private/protocol/timestamp.go
Expand Up @@ -28,7 +28,7 @@ const (
ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z"

// This format is used for output time without seconds precision
ISO8601OutputTimeFormat = "2006-01-02T15:04:05Z"
ISO8601OutputTimeFormat = "2006-01-02T15:04:05.999999999Z"
)

// IsKnownTimestampFormat returns if the timestamp format name
Expand Down
7 changes: 6 additions & 1 deletion private/protocol/timestamp_test.go
Expand Up @@ -26,13 +26,18 @@ func TestFormatTime(t *testing.T) {
"ISO8601Test1": {
formatName: ISO8601TimeFormatName,
expectedOutput: "2000-01-02T20:34:56Z",
input: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC),
input: time.Date(2000, time.January, 2, 20, 34, 56, 0, time.UTC),
},
"RFC822Test1": {
formatName: RFC822TimeFormatName,
expectedOutput: "Sun, 02 Jan 2000 20:34:56 GMT",
input: time.Date(2000, time.January, 2, 20, 34, 56, 0, time.UTC),
},
"ISO8601Test2": {
formatName: ISO8601TimeFormatName,
expectedOutput: "2000-01-02T20:34:56.123Z",
input: time.Date(2000, time.January, 2, 20, 34, 56, .123e9, time.UTC),
},
}

for name, c := range cases {
Expand Down

0 comments on commit 9a0ad8b

Please sign in to comment.