µOS++ IIIe Reference  v6.3.15
“Perfekt ist nicht gut genug”
The third edition of µOS++, a POSIX inspired open source system, written in C++.
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 52 of file timegm.c.

◆ _DAYS_IN_YEAR

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

Definition at line 58 of file timegm.c.

◆ _ISLEAP

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

Definition at line 57 of file timegm.c.

◆ _SEC_IN_DAY

#define _SEC_IN_DAY   86400L

Definition at line 47 of file timegm.c.

◆ _SEC_IN_HOUR

#define _SEC_IN_HOUR   3600L

Definition at line 46 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 45 of file timegm.c.

Function Documentation

◆ timegm()

time_t timegm ( struct tm *  tim_p)

Definition at line 71 of file timegm.c.

◆ validate_structure()

static void validate_structure ( struct tm *  tim_p)
static

Definition at line 124 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 54 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 49 of file timegm.c.