MCPcopy Create free account
hub / github.com/containerd/nerdctl / parseTimestamp

Function parseTimestamp

pkg/timestamp/timestamp.go:137–158  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

135}
136
137func parseTimestamp(value string) (seconds int64, nanoseconds int64, _ error) {
138 s, n, ok := strings.Cut(value, ".")
139 sec, err := strconv.ParseInt(s, 10, 64)
140 if err != nil {
141 return sec, 0, err
142 }
143 if !ok {
144 return sec, 0, nil
145 }
146 if len(n) > 9 {
147 n = n[:9]
148 }
149 nsec, err := strconv.ParseInt(n, 10, 64)
150 if err != nil {
151 return sec, nsec, err
152 }
153 // should already be in nanoseconds but just in case convert n to nanoseconds
154 for range 9 - len(n) {
155 nsec *= 10
156 }
157 return sec, nsec, nil
158}

Callers 2

GetTimestampFunction · 0.85
ParseTimestampsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…