MCPcopy Index your code
hub / github.com/google/mangle / parseTimestamp

Function parseTimestamp

parse/parse.go:899–914  ·  view source on GitHub ↗

parseTimestamp parses a timestamp string in ISO 8601 format.

(s string)

Source from the content-addressed store, hash-verified

897
898// parseTimestamp parses a timestamp string in ISO 8601 format.
899func parseTimestamp(s string) (time.Time, error) {
900 // Try various formats
901 formats := []string{
902 "2006-01-02T15:04:05Z",
903 "2006-01-02T15:04:05",
904 "2006-01-02",
905 }
906
907 for _, format := range formats {
908 if t, err := time.Parse(format, s); err == nil {
909 return t, nil
910 }
911 }
912
913 return time.Time{}, fmt.Errorf("unable to parse timestamp: %s", s)
914}
915
916// parseDuration parses a duration string like "7d", "24h", "30m", "1s", "500ms".
917// parseDuration parses a Go-style duration string.

Callers 2

VisitTemporalBoundMethod · 0.85
TestParseTimestampFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseTimestampFunction · 0.68