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

  1. Update oh-my-posh to the latest version
  2. Inspect the raw API response for data.timings.Maghrib to see the actual format
  3. Change the `method` segment option to get standard-formatted timings
  4. 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

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

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/7a1a66c167a27090. Report an issue: GitHub.