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

Time related utilities. More...

#include <time.h>
#include "sarmfsw.h"
Include dependency graph for time_utils.h:
This graph shows which files directly or indirectly include this file:

Data Structures

struct  DateTime
 Basic Date & Time struct. More...
 

Typedefs

typedef enum eMonths eMonths
 
typedef enum eWeekdays eWeekdays
 
typedef struct DateTime DateTime
 

Enumerations

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...
 

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.
 
bool is_LeapYear (const uint32_t year)
 Determine if given year is leap.
 
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

Typedef Documentation

◆ DateTime

typedef struct DateTime DateTime

◆ eMonths

typedef enum eMonths eMonths

◆ eWeekdays

typedef enum eWeekdays eWeekdays

Enumeration Type Documentation

◆ eMonths

enum 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

enum eWeekdays

Weekdays enumeration.

Enumerator
Sunday 

Sunday.

Monday 

Monday.

Tuesday 

Tuesday.

Wednesday 

Wednesday.

Thursday 

Thursday.

Friday 

Friday.

Saturday 

Saturday.

Weekdays_Max 

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:

◆ is_LeapYear()

bool is_LeapYear ( const uint32_t year)
inline

Determine if given year is leap.

Parameters
[in]year- Year to test
Returns
true if leap year / false otherwise
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: