MCPcopy Create free account
hub / github.com/github/gh-aw / normalizeTimeTokens

Function normalizeTimeTokens

pkg/parser/schedule_time_utils.go:44–68  ·  view source on GitHub ↗

normalizeTimeTokens combines time tokens into a normalized string Handles time, AM/PM, and timezone tokens

(tokens []string)

Source from the content-addressed store, hash-verified

42// normalizeTimeTokens combines time tokens into a normalized string
43// Handles time, AM/PM, and timezone tokens
44func normalizeTimeTokens(tokens []string) string {
45 scheduleTimeUtilsLog.Printf("Normalizing time tokens: %v", tokens)
46 if len(tokens) == 0 {
47 return ""
48 }
49
50 timeStr := tokens[0]
51 nextIndex := 1
52 if len(tokens) > 1 && isAMPMToken(tokens[1]) {
53 timeStr += " " + tokens[1]
54 nextIndex = 2
55 }
56
57 if len(tokens) > nextIndex {
58 timezoneToken := strings.ToLower(tokens[nextIndex])
59 if strings.HasPrefix(timezoneToken, "utc") {
60 timeStr = timeStr + " " + timezoneToken
61 } else if normalized, ok := normalizeTimezoneAbbreviation(timezoneToken); ok {
62 timeStr = timeStr + " " + normalized
63 }
64 }
65
66 scheduleTimeUtilsLog.Printf("Normalized time string: %q", timeStr)
67 return timeStr
68}
69
70// parseTimeToMinutes converts hour and minute strings to total minutes since midnight
71// Invalid hour/minute strings are treated as zero to preserve existing behavior.

Callers 5

TestNormalizeTimeTokensFunction · 0.85
extractTimeMethod · 0.85
extractTimeBetweenMethod · 0.85
extractTimeAfterMethod · 0.85

Calls 4

isAMPMTokenFunction · 0.85
ToLowerMethod · 0.80
PrintfMethod · 0.45

Tested by 1

TestNormalizeTimeTokensFunction · 0.68