MCPcopy Index your code
hub / github.com/google/go-github / parseTokenExpiration

Function parseTokenExpiration

github/github.go:1116–1128  ·  view source on GitHub ↗

parseTokenExpiration parses the TokenExpiration related headers. Returns 0001-01-01 if the header is not defined or could not be parsed.

(r *http.Response)

Source from the content-addressed store, hash-verified

1114// parseTokenExpiration parses the TokenExpiration related headers.
1115// Returns 0001-01-01 if the header is not defined or could not be parsed.
1116func parseTokenExpiration(r *http.Response) Timestamp {
1117 if v := r.Header.Get(headerTokenExpiration); v != "" {
1118 if t, err := time.Parse("2006-01-02 15:04:05 MST", v); err == nil {
1119 return Timestamp{t.Local()}
1120 }
1121 // Some tokens include the timezone offset instead of the timezone.
1122 // https://github.com/google/go-github/issues/2649
1123 if t, err := time.Parse("2006-01-02 15:04:05 -0700", v); err == nil {
1124 return Timestamp{t.Local()}
1125 }
1126 }
1127 return Timestamp{} // 0001-01-01 00:00:00
1128}
1129
1130type requestContext uint8
1131

Callers 2

newResponseFunction · 0.85
TestParseTokenExpirationFunction · 0.85

Calls 1

GetMethod · 0.45

Tested by 1

TestParseTokenExpirationFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…