µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
timegm.c File Reference
#include <time.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define _DAYS_IN_MONTH(x)   ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
 
#define _DAYS_IN_YEAR(year)   (_ISLEAP(year) ? 366 : 365)
 
#define _ISLEAP(y)   (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
 
#define _SEC_IN_DAY   86400L
 
#define _SEC_IN_HOUR   3600L
 
#define _SEC_IN_MINUTE   60L
 

Functions

time_t timegm (struct tm *tim_p)
 
static void validate_structure (struct tm *tim_p)
 

Variables

static const int _DAYS_BEFORE_MONTH [12]
 
static const int DAYS_IN_MONTH [12]
 

Macro Definition Documentation

◆ _DAYS_IN_MONTH

#define _DAYS_IN_MONTH (   x)    ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])

Definition at line 37 of file timegm.c.

◆ _DAYS_IN_YEAR

#define _DAYS_IN_YEAR (   year)    (_ISLEAP(year) ? 366 : 365)

Definition at line 48 of file timegm.c.

◆ _ISLEAP

#define _ISLEAP (   y)    (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))

Definition at line 47 of file timegm.c.

◆ _SEC_IN_DAY

#define _SEC_IN_DAY   86400L

Definition at line 32 of file timegm.c.

◆ _SEC_IN_HOUR

#define _SEC_IN_HOUR   3600L

Definition at line 31 of file timegm.c.

◆ _SEC_IN_MINUTE

#define _SEC_IN_MINUTE   60L

As there is no timegm() function neither in newlib nor in POSIX, we add one here (based on a simplified newlib mktime()).

It is used in Chan FatFS to convert dates fields.

Definition at line 30 of file timegm.c.

Function Documentation

◆ timegm()

time_t timegm ( struct tm *  tim_p)

Definition at line 61 of file timegm.c.

◆ validate_structure()

static void validate_structure ( struct tm *  tim_p)
static

Definition at line 114 of file timegm.c.

Variable Documentation

◆ _DAYS_BEFORE_MONTH

const int _DAYS_BEFORE_MONTH[12]
static
Initial value:
=
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }

Definition at line 43 of file timegm.c.

◆ DAYS_IN_MONTH

const int DAYS_IN_MONTH[12]
static
Initial value:
=
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }

Definition at line 34 of file timegm.c.