JanDeDobbeleer/oh-my-posh · warning
failed to parse Iftar time: %w
Error message
failed to parse Iftar time: %w
What it means
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.
Source
Thrown at src/segments/ramadan.go:131
inRamadan, rozaNumber := r.resolveRamadanDay(now, data, firstRozaStr)
if !inRamadan && hideOutside {
return errNotRamadan
}
if inRamadan {
r.RozaNumber = rozaNumber
}
fajrTime, err := parseEventTime(now, data.Timings.Fajr)
if err != nil {
return fmt.Errorf("failed to parse Fajr time: %w", err)
}
iftarTime, err := parseEventTime(now, data.Timings.Maghrib)
if err != nil {
return fmt.Errorf("failed to parse Iftar time: %w", err)
}
imsakTime, err := parseEventTime(now, data.Timings.Imsak)
if err != nil {
return fmt.Errorf("failed to parse Imsak time: %w", err)
}
r.Fajr = fajrTime.Format("15:04")
r.Iftar = iftarTime.Format("15:04")
r.Imsak = imsakTime.Format("15:04")
// When past Iftar, fetch tomorrow's Fajr from the API for a DST-accurate countdown.
// Falls back to the same wall-clock time on the next calendar day if the fetch fails.
var tomorrowFajr time.Time
if !now.Before(iftarTime) {
tomorrow := now.AddDate(0, 0, 1)
var fetchErr error
tomorrowFajr, fetchErr = r.fetchFajrTime(tomorrow)View on GitHub (pinned to 0976794618)
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)
Example fix
// before: corrupted response "Maghrib": "" // parse fails: failed to parse Iftar time // after: retry with valid API response "Maghrib": "18:47"
Defensive patterns
Strategy: fallback
Validate before calling
const res = await fetch(apiUrl);
const body = await res.json();
if (!body?.data?.timings?.Maghrib) throw new Error("missing Maghrib timing"); Type guard
function hasMaghrib(d) {
return d?.data?.timings?.Maghrib != null && /\d{1,2}:\d{2}/.test(d.data.timings.Maghrib);
} Try / catch
try {
const t = parseEventTime(now, data.Timings.Maghrib);
} catch (e) {
// fall back to rendering without Iftar time
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: Aladhan API response with unusual timing format for the configured method, upstream API schema change, corrupted/proxied HTTP response.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse Fajr time: %w
- failed to parse Imsak time: %w
- unable to get data for team %s
- no elements in the array
- Withings API error: <status>
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/7a1a66c167a27090.
Report an issue: GitHub.