Time related utilities.
More...
#include <time.h>
#include "sarmfsw.h"
#include "time_utils.h"
Time related utilities.
- Author
- SMFSW
- Copyright
- MIT (c) 2017-2024, SMFSW
◆ DateTime2time_t()
time_t DateTime2time_t |
( |
const DateTime *const | time | ) |
|
Convert DateTime to time_t.
- Parameters
-
[in] | time | - DateTime representation (broken down time) |
- Returns
- time_t representation
◆ diffDateTime()
Calculate DateTime difference.
- Parameters
-
[in] | time2 | - pointer to closest DateTime representation (broken down time) |
[in] | time1 | - pointer to oldest DateTime representation (broken down time) |
- Returns
- DateTime difference
◆ Get_Day_str()
const char * Get_Day_str |
( |
const eWeekdays | day | ) |
|
Get weekday name string.
- Parameters
-
- Returns
- Weekday string pointer
◆ Get_Month_str()
const char * Get_Month_str |
( |
const eMonths | month | ) |
|
Get month name string.
- Parameters
-
- Returns
- Month string pointer
◆ Get_Weekday()
eWeekdays Get_Weekday |
( |
uint16_t | year, |
|
|
uint8_t | month, |
|
|
uint8_t | day ) |
Determine weekday for a given date.
- Note
- The algorithm works for dates between 1700 and 2399
- Warning
- month and day starts at 1, and no check is done to ensure the date is valid. You might be caught in a weekday from a void time if the date is not valid! You've been warned!!!
- Parameters
-
[in] | year | - Year of the given date |
[in] | month | - Month of the given date (1 to 12) |
[in] | day | - Day of the given date (1 to 31) |
- Returns
- true if leap year / false otherwise
◆ time_t2DateTime()
DateTime time_t2DateTime |
( |
const time_t | time | ) |
|
Convert time_t to DateTime.
- Parameters
-
[in] | time | - time_t representation |
- Returns
- Broken down time representation (DateTime)