Time related utilities.
More...
#include <time.h>
#include "sarmfsw.h"
|
enum | eMonths {
January = 1U
, February
, March
, April
,
May
, June
, July
, August
,
September
, October
, November
, December
,
Months_Max
} |
| Months enumeration. More...
|
|
enum | eWeekdays {
Sunday = 0U
, Monday
, Tuesday
, Wednesday
,
Thursday
, Friday
, Saturday
, Weekdays_Max
} |
| Weekdays enumeration. More...
|
|
Time related utilities.
- Author
- SMFSW
- Copyright
- MIT (c) 2017-2024, SMFSW
◆ DateTime
typedef struct DateTime DateTime |
◆ eMonths
◆ eWeekdays
◆ eMonths
Months enumeration.
Enumerator |
---|
January | January.
|
February | February.
|
March | March.
|
April | April.
|
May | May.
|
June | June.
|
July | July.
|
August | August.
|
September | September.
|
October | October.
|
November | November.
|
December | December.
|
Months_Max | |
◆ eWeekdays
Weekdays enumeration.
Enumerator |
---|
Sunday | Sunday.
|
Monday | Monday.
|
Tuesday | Tuesday.
|
Wednesday | Wednesday.
|
Thursday | Thursday.
|
Friday | Friday.
|
Saturday | Saturday.
|
Weekdays_Max | |
◆ 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
◆ is_LeapYear()
bool is_LeapYear |
( |
const uint32_t | year | ) |
|
|
inline |
Determine if given year is leap.
- Parameters
-
- 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)