MCPcopy Index your code
hub / github.com/github/github-mcp-server / parseISOTimestamp

Function parseISOTimestamp

pkg/github/issues.go:2808–2827  ·  view source on GitHub ↗

parseISOTimestamp parses an ISO 8601 timestamp string into a time.Time object. Returns the parsed time or an error if parsing fails. Example formats supported: "2023-01-15T14:30:00Z", "2023-01-15"

(timestamp string)

Source from the content-addressed store, hash-verified

2806// Returns the parsed time or an error if parsing fails.
2807// Example formats supported: "2023-01-15T14:30:00Z", "2023-01-15"
2808func parseISOTimestamp(timestamp string) (time.Time, error) {
2809 if timestamp == "" {
2810 return time.Time{}, fmt.Errorf("empty timestamp")
2811 }
2812
2813 // Try RFC3339 format (standard ISO 8601 with time)
2814 t, err := time.Parse(time.RFC3339, timestamp)
2815 if err == nil {
2816 return t, nil
2817 }
2818
2819 // Try simple date format (YYYY-MM-DD)
2820 t, err = time.Parse("2006-01-02", timestamp)
2821 if err == nil {
2822 return t, nil
2823 }
2824
2825 // Return error with supported formats
2826 return time.Time{}, fmt.Errorf("invalid ISO 8601 timestamp: %s (supported formats: YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DD)", timestamp)
2827}

Callers 4

ListCommitsFunction · 0.85
ListIssuesFunction · 0.85
Test_ParseISOTimestampFunction · 0.85
ListGistsFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_ParseISOTimestampFunction · 0.68