mbgtools-lx  4.2.8
mbgmktm.c File Reference
#include <mbgmktm.h>
#include <assert.h>

Go to the source code of this file.

Macros

#define _MBGMKTM
 

Functions

time_t mbg_mktime (int year, int month, int day, int hour, int min, int sec)
 Compute a linear time_t value from broken down date and time. More...
 

Variables

static const char Days [12]
 
static int YDays [12]
 

Macro Definition Documentation

◆ _MBGMKTM

#define _MBGMKTM

Definition at line 23 of file mbgmktm.c.

Function Documentation

◆ mbg_mktime()

time_t mbg_mktime ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)

Compute a linear time_t value from broken down date and time.

This function works like the standard mktime() function but does not account for a timezone setting configured for the standard C library. Also, it does not take a structure but a set of variables which makes it more versatile. The accepted variables are in the same ranges as the struct tm members used by mktime().

Parameters
[in]yearyear number - 1900
[in]monthmonths since January, 0..11
[in]daydays after 1st, 0..30
[in]hour0..23
[in]min0..59
[in]sec0..59, 60 if leap second
Returns
seconds since 1970-01-01 (Unix time_t format) or ((time_t) -1) if range overflow

Definition at line 61 of file mbgmktm.c.

References Days, and YDays.

Referenced by pcps_mktime(), and tm_gps_to_nano_time_64().

Variable Documentation

◆ Days

const char Days[12]
static
Initial value:
=
{
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
}

Definition at line 30 of file mbgmktm.c.

Referenced by mbg_mktime().

◆ YDays

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

Definition at line 35 of file mbgmktm.c.

Referenced by mbg_mktime().