parseUTCOffset parses UTC offset strings (e.g., utc+9, utc-5, utc+09:00, utc-05:30) Returns the offset in minutes
(offsetStr string)
| 166 | // parseUTCOffset parses UTC offset strings (e.g., utc+9, utc-5, utc+09:00, utc-05:30) |
| 167 | // Returns the offset in minutes |
| 168 | func parseUTCOffset(offsetStr string) int { |
| 169 | // Parse UTC offset (e.g., utc+9, utc-5, utc+09:00, utc-05:30) |
| 170 | if len(offsetStr) <= 3 { |
| 171 | return 0 |
| 172 | } |
| 173 | |
| 174 | offsetPart := offsetStr[3:] // Skip "utc" |
| 175 | sign := 1 |
| 176 | if strings.HasPrefix(offsetPart, "+") { |
| 177 | offsetPart = offsetPart[1:] |
| 178 | } else if strings.HasPrefix(offsetPart, "-") { |
| 179 | sign = -1 |
| 180 | offsetPart = offsetPart[1:] |
| 181 | } |
| 182 | |
| 183 | // Check if it's HH:MM format |
| 184 | if strings.Contains(offsetPart, ":") { |
| 185 | offsetParts := strings.Split(offsetPart, ":") |
| 186 | if len(offsetParts) == 2 { |
| 187 | hours, err1 := strconv.Atoi(offsetParts[0]) |
| 188 | mins, err2 := strconv.Atoi(offsetParts[1]) |
| 189 | if err1 == nil && err2 == nil { |
| 190 | return sign * (hours*60 + mins) |
| 191 | } |
| 192 | } |
| 193 | return 0 |
| 194 | } |
| 195 | |
| 196 | // Just hours (e.g., utc+9) |
| 197 | hours, err := strconv.Atoi(offsetPart) |
| 198 | if err != nil { |
| 199 | return 0 |
| 200 | } |
| 201 | return sign * hours * 60 |
| 202 | } |
| 203 | |
| 204 | // parseHourMinute parses time parts in HH:MM or HH format |
| 205 | // Returns hour, minute, and success flag |
no outgoing calls