HARMcksL: ARM HAL toolbox (yet STM32 oriented) 1.6
SMFSW collection of HAL hacks for STM32
Loading...
Searching...
No Matches
time_utils.c File Reference

Time related utilities. More...

#include <time.h>
#include "sarmfsw.h"
#include "time_utils.h"
Include dependency graph for time_utils.c:

Functions

const char * Get_Day_str (const eWeekdays day)
 Get weekday name string.
 
const char * Get_Month_str (const eMonths month)
 Get month name string.
 
eWeekdays Get_Weekday (uint16_t year, uint8_t month, uint8_t day)
 Determine weekday for a given date.
 
DateTime time_t2DateTime (const time_t time)
 Convert time_t to DateTime.
 
time_t DateTime2time_t (const DateTime *const time)
 Convert DateTime to time_t.
 
DateTime diffDateTime (const DateTime *const time2, const DateTime *const time1)
 Calculate DateTime difference.
 

Detailed Description

Time related utilities.

Author
SMFSW

Function Documentation

◆ 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
Here is the caller graph for this function:

◆ diffDateTime()

DateTime diffDateTime ( const DateTime *const time2,
const DateTime *const time1 )

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
Here is the call graph for this function:

◆ Get_Day_str()

const char * Get_Day_str ( const eWeekdays day)

Get weekday name string.

Parameters
[in]day- Weekday from eWeekdays enum
Returns
Weekday string pointer

◆ Get_Month_str()

const char * Get_Month_str ( const eMonths month)

Get month name string.

Parameters
[in]month- Month from eMonths enum
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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)
Here is the caller graph for this function: