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

A stretch of the day as an axis, and the sums that put a moment somewhere along it. More...

#include <stdbool.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  TimeBand
 The stretch of day a band shows: where it starts and how long it runs. More...
struct  TimeBandSpan
 A span clipped to the window, in minutes past the window's start. More...

Macros

#define TIMEBAND_DAY_MINUTES   1440
 Minutes in a day, the modulus every wrap here is taken over.

Functions

TimeBand timeband_full_day (void)
 A window running midnight to midnight.
TimeBand timeband_rolling (int now_min, int span_min, int lead_min)
 A window that puts a given moment a fixed way into it.
TimeBand timeband_from_hour (int base_hour, int span_min)
 A window starting at the top of a given hour.
int timeband_offset (TimeBand band, int minute_of_day)
 How far into the window a minute of the day falls.
int timeband_pos (TimeBand band, int length, int minute_of_day)
 Where a minute of the day lands along an axis of a given length.
int timeband_pos_offset (TimeBand band, int length, int offset_min)
 The same mapping for a value already measured from the window's start.
bool timeband_clip (TimeBand band, time_t window_epoch, time_t start, time_t end, TimeBandSpan *out)
 Clip an absolute span onto the window.
int timeband_clip_daily (TimeBand band, int from_min, int to_min, TimeBandSpan *out, int max_out)
 Clip a daily span, one that repeats every day like the daylight, onto the window.
time_t timeband_window_epoch (TimeBand band, time_t now, int now_min)
 The epoch the window's first minute sits at.

Detailed Description

A stretch of the day as an axis, and the sums that put a moment somewhere along it.

A face that draws the day as one line has the same problem everywhere it looks: the line may start at any hour and run past midnight, so every reading it wants to place has to be measured against that start rather than against midnight. Doing that at each drawing site is where the wrapping bugs live, so it is done once here and nothing downstream ever sees a wrap.

Everything handed back is an offset from the window's start, counting up. That is what lets the same sums serve a ribbon and a ring: the ribbon asks for a position along its pixels and the ring asks for one along a full turn, and neither ever gets a span that runs backwards.

The axis unit is the caller's, so nothing here reaches for a GRect or an angle.