package radarfetch import ( "strconv" "strings" "time" ) // ParseNmcTime parses like "MM/DD HH:MM" with a local tz offset (hours). func ParseNmcTime(s string, tzOffset int) (date int, hour int, minute int, tsLocal string) { parts := strings.Fields(s) if len(parts) >= 2 { md := strings.Split(parts[0], "/") hm := strings.Split(parts[1], ":") if len(md) == 2 && len(hm) == 2 { now := time.Now().UTC().Add(time.Duration(tzOffset) * time.Hour) y := now.Year() m, _ := strconv.Atoi(md[0]) d, _ := strconv.Atoi(md[1]) h, _ := strconv.Atoi(hm[0]) mm, _ := strconv.Atoi(hm[1]) loc := time.FixedZone("LOCAL", tzOffset*3600) t := time.Date(y, time.Month(m), d, h, mm, 0, 0, loc) date = t.Year()*10000 + int(t.Month())*100 + t.Day() hour = t.Hour() minute = t.Minute() tsLocal = t.Format("2006-01-02 15:04:05") return } } now := time.Now().UTC().Add(time.Duration(tzOffset) * time.Hour) date = now.Year()*10000 + int(now.Month())*100 + now.Day() hour = now.Hour() minute = now.Minute() tsLocal = now.Format("2006-01-02 15:04:05") return }