(xepgChannel XEPGChannelStruct, channelId string)
| 1336 | } |
| 1337 | |
| 1338 | func createLiveProgram(xepgChannel XEPGChannelStruct, channelId string) []*Program { |
| 1339 | var programs []*Program |
| 1340 | |
| 1341 | var currentTime = time.Now() |
| 1342 | localLocation := currentTime.Location() // Central Time (CT) |
| 1343 | |
| 1344 | startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, currentTime.Nanosecond(), localLocation) |
| 1345 | stopTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, currentTime.Nanosecond(), localLocation) |
| 1346 | |
| 1347 | name := "" |
| 1348 | if xepgChannel.XName != "" { |
| 1349 | name = xepgChannel.XName |
| 1350 | } else { |
| 1351 | name = xepgChannel.TvgName |
| 1352 | } |
| 1353 | |
| 1354 | // Search for Datetime or Time |
| 1355 | // Datetime examples: '12/31-11:59 PM', '1.1 6:30 AM', '09/15-10:00PM', '7/4 12:00 PM', '3.21 3:45 AM', '6/30-8:00 AM', '4/15 3AM' |
| 1356 | // Time examples: '11:59 PM', '6:30 AM', '11:59PM', '1PM' |
| 1357 | re := regexp.MustCompile(`((\d{1,2}[./]\d{1,2})[-\s])*(\d{1,2}(:\d{2})*\s*(AM|PM)?(?:\s*(ET|CT|MT|PT|EST|CST|MST|PST))?)`) |
| 1358 | matches := re.FindStringSubmatch(name) |
| 1359 | layout := "2006.1.2 3:04 PM" |
| 1360 | if len(matches) > 0 { |
| 1361 | timePart := matches[len(matches)-2] |
| 1362 | if timePart == "" { |
| 1363 | timePart = matches[len(matches)-1] |
| 1364 | } |
| 1365 | |
| 1366 | timeString := strings.TrimSpace(timePart) |
| 1367 | timeString = strings.ReplaceAll(timeString, " ", " ") |
| 1368 | |
| 1369 | // Handle timezone if present |
| 1370 | var location *time.Location |
| 1371 | if strings.Contains(timeString, "ET") || strings.Contains(timeString, "EST") { |
| 1372 | location, _ = time.LoadLocation("America/New_York") |
| 1373 | } else if strings.Contains(timeString, "CT") || strings.Contains(timeString, "CST") { |
| 1374 | location, _ = time.LoadLocation("America/Chicago") |
| 1375 | } else if strings.Contains(timeString, "MT") || strings.Contains(timeString, "MST") { |
| 1376 | location, _ = time.LoadLocation("America/Denver") |
| 1377 | } else if strings.Contains(timeString, "PT") || strings.Contains(timeString, "PST") { |
| 1378 | location, _ = time.LoadLocation("America/Los_Angeles") |
| 1379 | } else { |
| 1380 | location = currentTime.Location() |
| 1381 | } |
| 1382 | |
| 1383 | // Remove timezone from timeString |
| 1384 | timeString = strings.ReplaceAll(timeString, "ET", "") |
| 1385 | timeString = strings.ReplaceAll(timeString, "CT", "") |
| 1386 | timeString = strings.ReplaceAll(timeString, "MT", "") |
| 1387 | timeString = strings.ReplaceAll(timeString, "PT", "") |
| 1388 | timeString = strings.ReplaceAll(timeString, "EST", "") |
| 1389 | timeString = strings.ReplaceAll(timeString, "CST", "") |
| 1390 | timeString = strings.ReplaceAll(timeString, "MST", "") |
| 1391 | timeString = strings.ReplaceAll(timeString, "PST", "") |
| 1392 | timeString = strings.TrimSpace(timeString) |
| 1393 | |
| 1394 | // Handle different date formats |
| 1395 | var datePart string |
no outgoing calls
no test coverage detected