JanDeDobbeleer/oh-my-posh · warning

failed to parse Fajr time: %w

Error message

failed to parse Fajr time: %w

What it means

The ramadan segment fetches prayer times from the Aladhan API and parses the Fajr timing string (e.g. "05:12 (EET)") into a time.Time for the current day via parseEventTime. This error wraps whatever went wrong during that parse — typically the timing string from the API does not match the expected time format.

Source

Thrown at src/segments/ramadan.go:126

	data := response.Data

	// Determine if we are currently in Ramadan and compute the roza number.
	firstRozaStr := r.options.String(RamadanFirstRozaDate, "")
	hideOutside := r.options.Bool(RamadanHideOutside, true)

	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.

View on GitHub (pinned to 0976794618)

Solutions

  1. Update oh-my-posh to the latest version so the parser matches the current Aladhan API format
  2. Call the API URL manually (the segment logs it) and inspect data.timings.Fajr to see the actual format
  3. Try a different `method` value in the segment options, which changes the timing format returned
  4. Check network health — a captive portal or error page can corrupt the response

Example fix

// before: API returns Fajr as "05:12" but with suffix
"Fajr": "05:12 (EET)"  // parse fails
// after: update oh-my-posh / choose method option that returns "05:12"
[[blocks.segments]]
type = "ramadan"
[blocks.segments.properties]
method = 2
Defensive patterns

Strategy: fallback

Validate before calling

const res = await fetch(apiUrl);
const body = await res.json();
if (!body?.data?.timings?.Fajr) throw new Error("missing Fajr timing");

Type guard

function hasFajr(d) {
  return d?.data?.timings?.Fajr != null && /\d{1,2}:\d{2}/.test(d.data.timings.Fajr);
}

Try / catch

try {
  const t = parseEventTime(now, data.Timings.Fajr);
} catch (e) {
  // fall back to hiding the segment rather than failing the prompt
}

Prevention

When it happens

Trigger: The Aladhan API response's data.timings.Fajr is missing, empty, or in an unexpected format (e.g. includes a timezone suffix or 12-hour format the parser doesn't accept), or the API schema changed.

Common situations: API returns timings in a different convention for some methods/schools, a proxy/captive portal returns HTML instead of JSON-ish timings, upstream schema change in Aladhan API responses.

Understand the failure class

Related errors


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