Loading...
Searching...
No Matches
solar.h File Reference

How the day's light is going, worked out from three plain clock readings. More...

#include <stdbool.h>

Go to the source code of this file.

Functions

int solar_day_progress (int rise, int set, int now)
 How far through the daylight it is, from 0 at sunrise to 100 at sunset.
int solar_night_progress (int rise, int set, int now)
 How far through the night it is, from 0 at sunset to 100 at the next sunrise.
int solar_next_event (int rise, int set, int now, bool *is_sunrise)
 Minutes until the next sun event, and which one it is.

Detailed Description

How the day's light is going, worked out from three plain clock readings.

Sunrise, sunset, and now all arrive as minutes past midnight, so this is pure arithmetic with no watch behind it. Reading the phone's strings and the clock is the caller's job. Handing over the three numbers is the seam. Any reading of -1 means the caller had nothing, and every function here answers "no data" for it rather than doing maths on a missing time. Sunrise and sunset on the same minute count as no data too, since a sun that never sets and one that never rises can both arrive that way.

The daylight is measured forward round the clock from sunrise, so a sunset after midnight, as in a high latitude summer, works the same as an ordinary one.