{"record":{"id":"8ed69135e3edee5a","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-parse-imsak-time-w","errorCode":null,"errorMessage":"failed to parse Imsak time: %w","messagePattern":"failed to parse Imsak time: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/ramadan.go","lineNumber":136,"sourceCode":"\t}\n\n\tif inRamadan {\n\t\tr.RozaNumber = rozaNumber\n\t}\n\n\tfajrTime, err := parseEventTime(now, data.Timings.Fajr)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse Fajr time: %w\", err)\n\t}\n\n\tiftarTime, err := parseEventTime(now, data.Timings.Maghrib)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse Iftar time: %w\", err)\n\t}\n\n\timsakTime, err := parseEventTime(now, data.Timings.Imsak)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse Imsak time: %w\", err)\n\t}\n\n\tr.Fajr = fajrTime.Format(\"15:04\")\n\tr.Iftar = iftarTime.Format(\"15:04\")\n\tr.Imsak = imsakTime.Format(\"15:04\")\n\n\t// When past Iftar, fetch tomorrow's Fajr from the API for a DST-accurate countdown.\n\t// Falls back to the same wall-clock time on the next calendar day if the fetch fails.\n\tvar tomorrowFajr time.Time\n\tif !now.Before(iftarTime) {\n\t\ttomorrow := now.AddDate(0, 0, 1)\n\t\tvar fetchErr error\n\t\ttomorrowFajr, fetchErr = r.fetchFajrTime(tomorrow)\n\t\tif fetchErr != nil {\n\t\t\ttomorrowFajr = time.Date(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(),\n\t\t\t\tfajrTime.Hour(), fajrTime.Minute(), 0, 0, fajrTime.Location())\n\t\t}\n\t}","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/ramadan.go#L118-L154","documentation":"Same parseEventTime mechanism as the Fajr/Iftar errors, applied to data.timings.Imsak (the pre-dawn meal cutoff time). The parsed Imsak time is rendered alongside Fajr/Iftar, so a failure here aborts setData entirely.","triggerScenarios":"data.timings.Imsak is missing or in an unexpected format — notably some Aladhan API configurations omit Imsak or return it as an offset (e.g. \"05:00 (-10 min)\" relative to Fajr) that the parser cannot handle.","commonSituations":"Aladhan API tuning where Imsak is expressed as a Fajr offset, API schema drift, proxied/intercepted responses.","solutions":["Update oh-my-posh to the latest version","Inspect the raw API response's data.timings.Imsak field format","Change the `method` segment option so Imsak is returned as an absolute time","If your API config omits Imsak, upgrade or configure the segment to a method that includes it"],"exampleFix":"// before: Imsak as offset\n\"Imsak\": \"-10 min\"  // parse fails\n// after: method returning absolute time\n\"Imsak\": \"04:58\"","handlingStrategy":"fallback","validationCode":"const res = await fetch(apiUrl);\nconst body = await res.json();\nif (!body?.data?.timings?.Imsak) throw new Error(\"missing Imsak timing\");","typeGuard":"function hasImsak(d) {\n  return d?.data?.timings?.Imsak != null && /\\d{1,2}:\\d{2}/.test(d.data.timings.Imsak);\n}","tryCatchPattern":"try {\n  const t = parseEventTime(now, data.Timings.Imsak);\n} catch (e) {\n  // fall back to rendering without Imsak time\n}","preventionTips":["Keep oh-my-posh updated","Confirm the chosen Aladhan `method` returns Imsak as an absolute time (not an offset)","Verify the raw response's Imsak field format","Test connectivity to api.aladhan.com"],"tags":["go","http","time-parsing","api","ramadan-segment"],"backgroundTag":"time-string-parse-failed","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}