JanDeDobbeleer/oh-my-posh · warning

failed to parse Imsak time: %w

Error message

failed to parse Imsak time: %w

What it means

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.

Source

Thrown at src/segments/ramadan.go:136

	}

	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)
		if fetchErr != nil {
			tomorrowFajr = time.Date(tomorrow.Year(), tomorrow.Month(), tomorrow.Day(),
				fajrTime.Hour(), fajrTime.Minute(), 0, 0, fajrTime.Location())
		}
	}

View on GitHub (pinned to 0976794618)

Solutions

  1. Update oh-my-posh to the latest version
  2. Inspect the raw API response's data.timings.Imsak field format
  3. Change the `method` segment option so Imsak is returned as an absolute time
  4. If your API config omits Imsak, upgrade or configure the segment to a method that includes it

Example fix

// before: Imsak as offset
"Imsak": "-10 min"  // parse fails
// after: method returning absolute time
"Imsak": "04:58"
Defensive patterns

Strategy: fallback

Validate before calling

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

Type guard

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

Try / catch

try {
  const t = parseEventTime(now, data.Timings.Imsak);
} catch (e) {
  // fall back to rendering without Imsak time
}

Prevention

When it happens

Trigger: 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.

Common situations: Aladhan API tuning where Imsak is expressed as a Fajr offset, API schema drift, proxied/intercepted responses.

Understand the failure class

Related errors


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