normalizeTimeTokens combines time tokens into a normalized string Handles time, AM/PM, and timezone tokens
(tokens []string)
| 42 | // normalizeTimeTokens combines time tokens into a normalized string |
| 43 | // Handles time, AM/PM, and timezone tokens |
| 44 | func 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. |