MCPcopy Index your code
hub / github.com/dunglas/httpsfv / parseDate

Function parseDate

date.go:24–41  ·  view source on GitHub ↗

parseDate parses as defined in https://httpwg.org/specs/rfc9651.html#parse-date.

(s *scanner)

Source from the content-addressed store, hash-verified

22// parseDate parses as defined in
23// https://httpwg.org/specs/rfc9651.html#parse-date.
24func parseDate(s *scanner) (time.Time, error) {
25 if s.eof() || s.data[s.off] != '@' {
26 return time.Time{}, &UnmarshalError{s.off, ErrInvalidDateFormat}
27 }
28 s.off++
29
30 n, err := parseNumber(s)
31 if err != nil {
32 return time.Time{}, &UnmarshalError{s.off, ErrInvalidDateFormat}
33 }
34
35 i, ok := n.(int64)
36 if !ok {
37 return time.Time{}, &UnmarshalError{s.off, ErrInvalidDateFormat}
38 }
39
40 return time.Unix(i, 0), nil
41}

Callers 2

TestParseDateFunction · 0.85
parseBareItemFunction · 0.85

Calls 2

parseNumberFunction · 0.85
eofMethod · 0.80

Tested by 1

TestParseDateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…