|
Crinit -- Configurable Rootfs Init
|
Implementation of functions related to a single timer. More...
#include "timer.h"#include <assert.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#include "logio.h"
Functions | |
| static bool | crinitIsLeapYear (uint16_t year) |
| static const char * | crinitMonthToStr (uint8_t m) |
| static int | crinitMonthLength (uint8_t month, uint16_t year) |
| static bool | crinitNext (int last, uint8_t interval[2], int start, int limit, int *res, long long int *offs) |
| static bool | crinitNextYear (int last, uint16_t interval[2], int *res, long long int *offs) |
| static int | crinitDaysToMonth (uint8_t m, uint16_t year) |
| void | crinitTimerSetDefault (crinitTimerDef_t *td) |
| int | crinitSPrintTimerDef (char *s, crinitTimerDef_t *td) |
| void | crinitPrintTimerDef (crinitTimerDef_t *td) |
| bool | crinitCheckTimerDef (crinitTimerDef_t *td) |
| bool | crinitCheckTimerTime (struct timespec ts, crinitTimerDef_t *td) |
| struct tm * | crinitZonedTimeR (const time_t *time, int8_t timezone[2], struct tm *restrict result) |
| struct timespec | crinitTimerNextTime (struct timespec *last, crinitTimerDef_t *td) |
Variables | |
| static const char *const | crinitMonthLookup [] |
| static const int | crinitDayToMonthLookup [] |
Implementation of functions related to a single timer.
| bool crinitCheckTimerDef | ( | crinitTimerDef_t * | td | ) |
Check if a timer definition gives a valid timer ie. month between 1 and 12, day in 1 to 31, hours 0 to 23, ...
| td | the timer definition to set check |
| bool crinitCheckTimerTime | ( | struct timespec | ts, |
| crinitTimerDef_t * | td | ||
| ) |
Check if a timerstamp is valid for a timer
| ts | the timestamp to check. |
| td | the crinit timer definition to check against |
|
static |
Returns the number of days from start of the year to the first of the specified month ie. 0 for 1 (Jan), 31 for 2 (Feb), 59 (or 60 in a leap year) for 3 (Mar) and so on
| m | the month to get how many days the year had before the fist of it |
| year | the year to check in |
|
static |
check if a year is a leap year
| year | the year to check |
|
static |
Get the number of days a month is long.
| month | the month to get the length of |
| year | the year to know if Feb is 28 or 29 days long |
|
static |
get a static string with the short month name
| m | the month starting at 1 for Jan |
|
static |
Get the next value for a range.
| last | the value to get the next from |
| interval | the interval in which the next needs to be |
| start | the lowest possible value |
| limit | the highest possible value |
| res | next value after last |
| offs | the offset to the last value |
|
static |
get the next year
| last | the year from which to start finding the next |
| interval | the interval in which the next year needs to be in |
| res | the resulting next year |
| offs | the offset the next year has to the last |
| void crinitPrintTimerDef | ( | crinitTimerDef_t * | td | ) |
print a crinitTimerDef_t as crinitInfoPrint message
| td | the crinitTimerDef_t to print |
| int crinitSPrintTimerDef | ( | char * | s, |
| crinitTimerDef_t * | td | ||
| ) |
print a crinitTimerDef_t into a string
| s | the string to print to |
| td | the crinitTimerDef_t to print |
| struct timespec crinitTimerNextTime | ( | struct timespec * | last, |
| crinitTimerDef_t * | td | ||
| ) |
Calculate the next time the timer should trigger.
| last | the last timestamp to calculate the next from |
| td | the timer definition to calculate the next time from |
| void crinitTimerSetDefault | ( | crinitTimerDef_t * | td | ) |
Set a timer to the default value: Mon..Sun-0000..65535-01..12-01..31-00:00:00+0000
| td | the crinitTimerDef_t to set to default |
| struct tm * crinitZonedTimeR | ( | const time_t * | time, |
| int8_t | timezone[2], | ||
| struct tm *restrict | result | ||
| ) |
Get a struct tm similar to gmtime_r with a specific timezone.
| time | the timestamp to transform into a tm |
| timezone | the timezone with hour and minute |
| result | the resulting tm struct |
|
static |
|
static |