Skip to content

docs: document what the C prayer time fields and formatters do at high latitude - #30

Merged
rizukirr merged 1 commit into
mainfrom
libmuslim-formatter-contract
Aug 18, 2026
Merged

docs: document what the C prayer time fields and formatters do at high latitude#30
rizukirr merged 1 commit into
mainfrom
libmuslim-formatter-contract

Conversation

@rizukirr

Copy link
Copy Markdown
Member

Follow-up to libmuslim#57, which changed formatter behaviour, and libmuslim#56, which is still open.

What was missing

The formatter reference described neither of the two cases a caller actually has to handle, and the struct PrayerTimes reference implied every field lands inside a single day. It said only that a field is decimal hours in local time, with 17.75 as the example.

Both assumptions break at high latitude.

A field can be non-finite, because above roughly 66 degrees the Sun may never reach the altitude an event is defined by. A field can also fall below 0 or at or above 24, because the fajr and isha high-latitude fallback returns such values.

The part worth warning about

The out-of-range case is the dangerous one, and it is dangerous in a way that looks like tidying up.

A reader who converts a field into a timestamp and helpfully reduces it into 0 to 24 first will silently place the event on the wrong calendar day. The double is the only thing carrying that offset. Nothing else in the API expresses it, which is exactly why libmuslim#56 is still open.

So the caution tells the reader to check isfinite() and to keep the whole value when building an instant, rather than normalising it.

Formatter contract

Now documented, matching the upstream change.

 25.075  -> "01:05"      -0.104  -> "23:54"
 25.075  -> "01:04:30"   -0.104  -> "23:53:46"
    NaN  -> "--:--"         NaN  -> "--:--:--"

Both sentinels fit inside the buffer sizes already documented, 6 and 9 bytes, so those figures are unchanged and correct as they stand.

Every rendered value quoted was checked against the header rather than written from the description.

Not changed here, but worth a decision

The C overview still pins its download to v0.1.0.

curl -O https://raw.githubusercontent.com/muslimtify-org/libmuslim/v0.1.0/prayertimes.h

That tag predates the formatter fix, so a reader who follows the quick start gets a header where a high-latitude time can print as 00:-6. The docs would then describe behaviour the downloaded file does not have. Either a v0.1.1 tag or a change to the pin resolves it, and both are your call rather than something to slip into a docs PR.

The Rust and Dart pages need no change. Both already document their non-finite handling, Error::NonFiniteResult and PrayerTimesUnavailable, and neither exposes the raw out-of-range double.

Site builds clean.

…h latitude

The formatter reference described neither of the two cases a caller actually
has to handle, and the struct reference implied every field lands inside a
single day.

A field can be non-finite, because above roughly 66 degrees the Sun may never
reach the altitude an event is defined by. A field can also fall below 0 or at
or above 24, because the fajr and isha high-latitude fallback returns such
values, which means the event is on the previous or the next calendar day.

The second is the one worth warning about. A reader who converts a field into a
timestamp and reduces it into 0 to 24 first will silently place the event on
the wrong day, because the double is the only thing carrying the offset.

Also records the formatter contract added upstream in libmuslim#57. Values
outside 0 to 24 are reduced onto the clock face, so 25.075 renders as 01:05 and
-0.104 as 23:54, and non-finite values render as --:-- and --:--:--. Both
sentinels fit the buffer sizes already documented, so those are unchanged.

Every rendered value quoted here was checked against the header rather than
written from the description.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
muslimtify Ready Ready Preview Aug 18, 2026 1:30pm

@rizukirr
rizukirr merged commit 39ddc3d into main Aug 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant