Atlas › Test

TestMarshalTimestampFormats

Exact test identity: go.temporal.io/server/common/nexus/nexusrpc/TestMarshalTimestampFormats

Package
go.temporal.io/server/common/nexus/nexusrpc
Suite / test hierarchy
TestMarshalTimestampFormats
Test
TestMarshalTimestampFormats
Introduced at
timestamp.go ×1 Frontier kind: Joint frontier
Covered ranges
1
Covered lines
7
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/nexus/nexusrpc/timestamp.go 7 covered LOC · 1 range

Open complete file

15 // uses 0, 3, 6 or 9 fractional digits.
16 // Copied from https://github.com/protocolbuffers/protobuf-go/blob/0b2c87d84c27802dae7248480444e22421ba577d/encoding/protojson/well_known_types.go#L749C1-L826C2
17 > func marshalTimestamp(t time.Time) string { timestamp.go
18 > x := t.UTC().Format("2006-01-02T15:04:05.000000000")
19 > x = strings.TrimSuffix(x, "000")
20 > x = strings.TrimSuffix(x, "000")
21 > x = strings.TrimSuffix(x, ".000")
22 > return x + "Z"
23 > }
24
25 // unmarshalTimestamp unmarshals a string into a Time instance. Uses RFC 3339, with some extra validation to ensure that