Pure moon-phase math you can test off the watch. It counts from a known new moon using the average length of a moon cycle, so it needs nothing but a UTC timestamp. More...
#include <time.h>#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Macros | |
| #define | MOON_SYNODIC_SEC 2551443 |
| Average length of one moon cycle in seconds (about 29.53 days). | |
| #define | MOON_EPOCH_UTC 947182440 |
| A known new moon to count from: 2000-01-06 18:14 UTC. | |
Functions | |
| int32_t | moon_age_sec (time_t utc) |
| How far into the current moon cycle we are, in seconds. | |
| int | moon_glyph_index (time_t utc, int count) |
Picks one of count evenly spaced phase icons. It wraps back round at the end. | |
| int | moon_illumination_pct (time_t utc) |
| How lit up the moon looks, from 0 to 100. This is a rough straight-line guess, so it reads 0 at new moon and 100 at full. | |
| const char * | moon_phase_name (time_t utc) |
| Short name for the current phase (one of the eight main phases). | |
| int | moon_days_to_phase (time_t utc, bool to_full) |
| How many days until the next full or new moon, rounded to the nearest whole day. | |
Pure moon-phase math you can test off the watch. It counts from a known new moon using the average length of a moon cycle, so it needs nothing but a UTC timestamp.