Calendar arithmetic independent of the time zone and the RTC.
More...
|
| static bool | pbl_time_is_weekday (enum pbl_weekday day) |
| | Check whether a day is a working day (Monday to Friday).
|
| |
| static bool | pbl_time_is_weekend (enum pbl_weekday day) |
| | Check whether a day is on the weekend (Saturday or Sunday).
|
| |
| bool | pbl_time_is_leap_year (int year) |
| | Check whether a Gregorian year is a leap year.
|
| |
| int | pbl_time_days_in_month (int month, bool is_leap_year) |
| | Get the number of days in a month.
|
| |
| void | pbl_time_split_seconds (uint32_t seconds, uint32_t *days, uint32_t *hours, uint32_t *minutes, uint32_t *secs) |
| | Split a duration into days, hours, minutes and seconds.
|
| |
| int | pbl_time_display_hour (int hour, bool is_24h) |
| | Convert an hour of the day to the hour shown on a clock.
|
| |
| int | pbl_time_minute_of_day_adjust (int minute, int delta) |
| | Add a delta to a minute of the day, wrapping around midnight.
|
| |
| void | pbl_time_breakdown (time_t t, struct tm *tm) |
| | Fill the calendar fields of a struct tm from seconds since the epoch.
|
| |
Calendar arithmetic independent of the time zone and the RTC.
◆ PBL_EPOCH_WDAY
Day of the week of the Unix epoch (Thursday), as an enum pbl_weekday value.
◆ PBL_EPOCH_YEAR
| #define PBL_EPOCH_YEAR 1970 |
◆ PBL_TM_YEAR_ORIGIN
| #define PBL_TM_YEAR_ORIGIN 1900 |
Year that tm_year in struct tm counts from.
◆ pbl_weekday
Day of the week, numbered like tm_wday.
| Enumerator |
|---|
| PBL_SUNDAY | Sunday.
|
| PBL_MONDAY | Monday.
|
| PBL_TUESDAY | Tuesday.
|
| PBL_WEDNESDAY | Wednesday.
|
| PBL_THURSDAY | Thursday.
|
| PBL_FRIDAY | Friday.
|
| PBL_SATURDAY | Saturday.
|
◆ pbl_time_breakdown()
| void pbl_time_breakdown |
( |
time_t |
t, |
|
|
struct tm * |
tm |
|
) |
| |
Fill the calendar fields of a struct tm from seconds since the epoch.
Sets tm_sec to tm_yday. The DST, offset and zone fields are left untouched.
- Parameters
-
| t | Seconds since the Unix epoch. |
| [out] | tm | Broken-down time. |
◆ pbl_time_days_in_month()
| int pbl_time_days_in_month |
( |
int |
month, |
|
|
bool |
is_leap_year |
|
) |
| |
Get the number of days in a month.
- Parameters
-
| month | Month of the year, 1 (January) to 12 (December). |
| is_leap_year | Whether the year is a leap year. |
- Returns
- Number of days, 28 to 31.
◆ pbl_time_display_hour()
| int pbl_time_display_hour |
( |
int |
hour, |
|
|
bool |
is_24h |
|
) |
| |
Convert an hour of the day to the hour shown on a clock.
- Parameters
-
| hour | Hour of the day, 0 to 23. |
| is_24h | Whether the clock uses the 24-hour format. |
- Returns
hour on a 24-hour clock, or 1 to 12 on a 12-hour clock.
◆ pbl_time_is_leap_year()
| bool pbl_time_is_leap_year |
( |
int |
year | ) |
|
Check whether a Gregorian year is a leap year.
- Parameters
-
| year | Full year, e.g. 2024. |
- Returns
- true for a leap year.
◆ pbl_time_is_weekday()
| static bool pbl_time_is_weekday |
( |
enum pbl_weekday |
day | ) |
|
|
inlinestatic |
Check whether a day is a working day (Monday to Friday).
- Parameters
-
- Returns
- true for Monday to Friday.
References PBL_FRIDAY, and PBL_MONDAY.
◆ pbl_time_is_weekend()
| static bool pbl_time_is_weekend |
( |
enum pbl_weekday |
day | ) |
|
|
inlinestatic |
Check whether a day is on the weekend (Saturday or Sunday).
- Parameters
-
- Returns
- true for Saturday and Sunday.
References PBL_SATURDAY, and PBL_SUNDAY.
◆ pbl_time_minute_of_day_adjust()
| int pbl_time_minute_of_day_adjust |
( |
int |
minute, |
|
|
int |
delta |
|
) |
| |
Add a delta to a minute of the day, wrapping around midnight.
- Parameters
-
| minute | Minute of the day, 0 to 1439. |
| delta | Minutes to add, at most one day in either direction. |
- Returns
- Adjusted minute of the day, 0 to 1439.
◆ pbl_time_split_seconds()
| void pbl_time_split_seconds |
( |
uint32_t |
seconds, |
|
|
uint32_t * |
days, |
|
|
uint32_t * |
hours, |
|
|
uint32_t * |
minutes, |
|
|
uint32_t * |
secs |
|
) |
| |
Split a duration into days, hours, minutes and seconds.
- Parameters
-
| seconds | Duration in seconds. |
| [out] | days | Whole days. |
| [out] | hours | Remaining hours, 0 to 23. |
| [out] | minutes | Remaining minutes, 0 to 59. |
| [out] | secs | Remaining seconds, 0 to 59. |