{"record":{"id":"7a1a66c167a27090","repo":"JanDeDobbeleer/oh-my-posh","slug":"failed-to-parse-iftar-time-w","errorCode":null,"errorMessage":"failed to parse Iftar time: %w","messagePattern":"failed to parse Iftar time: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/segments/ramadan.go","lineNumber":131,"sourceCode":"\n\tinRamadan, rozaNumber := r.resolveRamadanDay(now, data, firstRozaStr)\n\n\tif !inRamadan && hideOutside {\n\t\treturn errNotRamadan\n\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)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/segments/ramadan.go#L113-L149","documentation":"Same parseEventTime mechanism as the Fajr error, but applied to data.timings.Maghrib, which becomes the Iftar (break-fast) time. This error wraps the parse failure of the Maghrib timing string returned by the Aladhan API.","triggerScenarios":"data.timings.Maghrib is absent, empty, or formatted in a way parseEventTime cannot handle for today's date (unexpected suffix, 12-hour clock, or schema drift).","commonSituations":"Aladhan API response with unusual timing format for the configured method, upstream API schema change, corrupted/proxied HTTP response.","solutions":["Update oh-my-posh to the latest version","Inspect the raw API response for data.timings.Maghrib to see the actual format","Change the `method` segment option to get standard-formatted timings","Verify the HTTP response isn't an error page (test connectivity to api.aladhan.com)"],"exampleFix":"// before: corrupted response\n\"Maghrib\": \"\"  // parse fails: failed to parse Iftar time\n// after: retry with valid API response\n\"Maghrib\": \"18:47\"","handlingStrategy":"fallback","validationCode":"const res = await fetch(apiUrl);\nconst body = await res.json();\nif (!body?.data?.timings?.Maghrib) throw new Error(\"missing Maghrib timing\");","typeGuard":"function hasMaghrib(d) {\n  return d?.data?.timings?.Maghrib != null && /\\d{1,2}:\\d{2}/.test(d.data.timings.Maghrib);\n}","tryCatchPattern":"try {\n  const t = parseEventTime(now, data.Timings.Maghrib);\n} catch (e) {\n  // fall back to rendering without Iftar time\n}","preventionTips":["Keep oh-my-posh updated for API schema changes","Verify data.timings.Maghrib exists in a raw API response","Use a standard `method` option value","Check for proxies intercepting API responses"],"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"}