Loading...
Searching...
No Matches
timeband.h
Go to the documentation of this file.
1
18#pragma once
19#include <stdbool.h>
20#include <time.h>
21
26
28#define TIMEBAND_DAY_MINUTES 1440
29
31typedef struct
32{
35} TimeBand;
36
39
49TimeBand timeband_rolling(int now_min, int span_min, int lead_min);
50
61TimeBand timeband_from_hour(int base_hour, int span_min);
62
71int timeband_offset(TimeBand band, int minute_of_day);
72
82int timeband_pos(TimeBand band, int length, int minute_of_day);
83
96int timeband_pos_offset(TimeBand band, int length, int offset_min);
97
99typedef struct
100{
101 int from;
102 int to;
106
124bool timeband_clip(TimeBand band, time_t window_epoch, time_t start, time_t end,
125 TimeBandSpan *out);
126
142int timeband_clip_daily(TimeBand band, int from_min, int to_min,
143 TimeBandSpan *out, int max_out);
144
164time_t timeband_window_epoch(TimeBand band, time_t now, int now_min);
165
bool timeband_clip(TimeBand band, time_t window_epoch, time_t start, time_t end, TimeBandSpan *out)
Clip an absolute span onto the window.
Definition timeband.c:115
TimeBand timeband_rolling(int now_min, int span_min, int lead_min)
A window that puts a given moment a fixed way into it.
Definition timeband.c:65
TimeBand timeband_from_hour(int base_hour, int span_min)
A window starting at the top of a given hour.
Definition timeband.c:74
TimeBand timeband_full_day(void)
A window running midnight to midnight.
Definition timeband.c:60
int timeband_pos_offset(TimeBand band, int length, int offset_min)
The same mapping for a value already measured from the window's start.
Definition timeband.c:103
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.
Definition timeband.c:92
time_t timeband_window_epoch(TimeBand band, time_t now, int now_min)
The epoch the window's first minute sits at.
Definition timeband.c:198
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.
Definition timeband.c:157
int timeband_offset(TimeBand band, int minute_of_day)
How far into the window a minute of the day falls.
Definition timeband.c:84
A span clipped to the window, in minutes past the window's start.
Definition timeband.h:100
int to
First minute past the span. Never below from + 1.
Definition timeband.h:102
int from
First minute past the window's start, 0 to span_min.
Definition timeband.h:101
bool clipped_start
The span began before the window opened.
Definition timeband.h:103
bool clipped_end
And ran past the end of it.
Definition timeband.h:104
The stretch of day a band shows: where it starts and how long it runs.
Definition timeband.h:32
int start_min
First minute of the window, 0 to 1439.
Definition timeband.h:33
int span_min
How many minutes it covers, 1 to 1440.
Definition timeband.h:34