BRL-CAD
time64.c File Reference
#include "common.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include "time64.h"
#include "time64_limits.h"
Include dependency graph for time64.c:

Go to the source code of this file.

Macros

#define days_in_gregorian_cycle   ((365 * 400) + 100 - 4 + 1)
 
#define MAX_SAFE_YEAR   2037
 
#define MIN_SAFE_YEAR   1971
 
#define SOLAR_CYCLE_LENGTH   28
 
#define CHEAT_DAYS   (1199145600 / 24 / 60 / 60)
 
#define CHEAT_YEARS   108
 
#define IS_LEAP(n)   ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) + 1900) % 100))) != 0)
 
#define WRAP(a, b, m)   ((a) = ((a) < 0 ) ? ((b)--, (a) + (m)) : (a))
 
#define SHOULD_USE_SYSTEM_LOCALTIME(a)   (0)
 
#define SHOULD_USE_SYSTEM_GMTIME(a)   (0)
 
#define TIME64_TRACE(format)   ((void)0)
 
#define TIME64_TRACE1(format, var1)   ((void)0)
 
#define TIME64_TRACE2(format, var1, var2)   ((void)0)
 
#define TIME64_TRACE3(format, var1, var2, var3)   ((void)0)
 

Functions

void initialize_mktime_maxmin ()
 
int cmp_date (const struct TM *left, const struct tm *right)
 
int date_in_safe_range (const struct TM *date, const struct tm *min, const struct tm *max)
 
Time64_T timegm64 (const struct TM *date)
 
void copy_tm_to_TM64 (const struct tm *src, struct TM *dest)
 
void copy_TM64_to_tm (const struct TM *src, struct tm *dest)
 
struct tm * fake_localtime_r (const time_t *ytime, struct tm *result)
 
struct tm * fake_gmtime_r (const time_t *ytime, struct tm *result)
 
Time64_T mktime64 (struct TM *input_date)
 
Time64_T timelocal64 (struct TM *date)
 
struct TMgmtime64_r (const Time64_T *in_time, struct TM *p)
 
struct TMlocaltime64_r (const Time64_T *ytime, struct TM *local_tm)
 
int valid_tm_wday (const struct TM *date)
 
int valid_tm_mon (const struct TM *date)
 
char * asctime64_r (const struct TM *date, char *result)
 
char * ctime64_r (const Time64_T *ytime, char *result)
 
struct TMlocaltime64 (const Time64_T *ytime)
 
struct TMgmtime64 (const Time64_T *ytime)
 
char * asctime64 (const struct TM *date)
 
char * ctime64 (const Time64_T *ytime)
 

Macro Definition Documentation

#define days_in_gregorian_cycle   ((365 * 400) + 100 - 4 + 1)

Definition at line 127 of file time64.c.

Referenced by gmtime64_r(), and timegm64().

#define MAX_SAFE_YEAR   2037

Definition at line 131 of file time64.c.

#define MIN_SAFE_YEAR   1971

Definition at line 132 of file time64.c.

#define SOLAR_CYCLE_LENGTH   28

Definition at line 135 of file time64.c.

#define CHEAT_DAYS   (1199145600 / 24 / 60 / 60)

Definition at line 175 of file time64.c.

Referenced by gmtime64_r().

#define CHEAT_YEARS   108

Definition at line 176 of file time64.c.

Referenced by gmtime64_r().

#define IS_LEAP (   n)    ((!(((n) + 1900) % 400) || (!(((n) + 1900) % 4) && (((n) + 1900) % 100))) != 0)

Definition at line 178 of file time64.c.

Referenced by gmtime64_r(), localtime64_r(), and timegm64().

#define WRAP (   a,
  b,
 
)    ((a) = ((a) < 0 ) ? ((b)--, (a) + (m)) : (a))

Definition at line 179 of file time64.c.

Referenced by gmtime64_r().

#define SHOULD_USE_SYSTEM_LOCALTIME (   a)    (0)

Definition at line 187 of file time64.c.

Referenced by localtime64_r().

#define SHOULD_USE_SYSTEM_GMTIME (   a)    (0)

Definition at line 196 of file time64.c.

Referenced by gmtime64_r().

#define TIME64_TRACE (   format)    ((void)0)

Definition at line 206 of file time64.c.

#define TIME64_TRACE1 (   format,
  var1 
)    ((void)0)

Definition at line 207 of file time64.c.

Referenced by localtime64_r().

#define TIME64_TRACE2 (   format,
  var1,
  var2 
)    ((void)0)

Definition at line 208 of file time64.c.

Referenced by localtime64_r().

#define TIME64_TRACE3 (   format,
  var1,
  var2,
  var3 
)    ((void)0)

Definition at line 209 of file time64.c.

Referenced by timegm64().

Function Documentation

void initialize_mktime_maxmin ( )

Definition at line 62 of file time64.c.

Referenced by mktime64().

int cmp_date ( const struct TM left,
const struct tm *  right 
)

Definition at line 226 of file time64.c.

Referenced by date_in_safe_range().

int date_in_safe_range ( const struct TM date,
const struct tm *  min,
const struct tm *  max 
)

Definition at line 264 of file time64.c.

References cmp_date().

Referenced by mktime64().

Here is the call graph for this function:

Time64_T timegm64 ( const struct TM date)

Definition at line 279 of file time64.c.

References days_in_gregorian_cycle, IS_LEAP, and TIME64_TRACE3.

Referenced by localtime64_r().

void copy_tm_to_TM64 ( const struct tm *  src,
struct TM dest 
)

Definition at line 445 of file time64.c.

References memset().

Referenced by gmtime64_r(), localtime64_r(), and mktime64().

Here is the call graph for this function:

void copy_TM64_to_tm ( const struct TM src,
struct tm *  dest 
)

Definition at line 477 of file time64.c.

References memset().

Referenced by mktime64().

Here is the call graph for this function:

struct tm* fake_localtime_r ( const time_t *  ytime,
struct tm *  result 
)

Definition at line 510 of file time64.c.

References memset().

Here is the call graph for this function:

struct tm* fake_gmtime_r ( const time_t *  ytime,
struct tm *  result 
)

Definition at line 527 of file time64.c.

References memset().

Here is the call graph for this function:

Time64_T mktime64 ( struct TM input_date)

Definition at line 568 of file time64.c.

References copy_TM64_to_tm(), copy_tm_to_TM64(), date_in_safe_range(), initialize_mktime_maxmin(), and TM.

Referenced by timelocal64().

Here is the call graph for this function:

Time64_T timelocal64 ( struct TM date)

Definition at line 609 of file time64.c.

References mktime64().

Here is the call graph for this function:

struct TM* gmtime64_r ( const Time64_T in_time,
struct TM p 
)

Definition at line 614 of file time64.c.

References CHEAT_DAYS, CHEAT_YEARS, copy_tm_to_TM64(), days_in_gregorian_cycle, GMTIME_R, IS_LEAP, SHOULD_USE_SYSTEM_GMTIME, and WRAP.

Referenced by gmtime64(), and localtime64_r().

Here is the call graph for this function:

struct TM* localtime64_r ( const Time64_T ytime,
struct TM local_tm 
)

Definition at line 741 of file time64.c.

References copy_tm_to_TM64(), gmtime64_r(), IS_LEAP, LOCALTIME_R, SHOULD_USE_SYSTEM_LOCALTIME, TIME64_TRACE1, TIME64_TRACE2, timegm64(), and TM.

Referenced by ctime64_r(), and localtime64().

Here is the call graph for this function:

int valid_tm_wday ( const struct TM date)

Definition at line 831 of file time64.c.

Referenced by asctime64_r().

int valid_tm_mon ( const struct TM date)

Definition at line 838 of file time64.c.

Referenced by asctime64_r().

char* asctime64_r ( const struct TM date,
char *  result 
)

Definition at line 846 of file time64.c.

References TM64_ASCTIME_FORMAT, valid_tm_mon(), and valid_tm_wday().

Referenced by asctime64(), and ctime64_r().

Here is the call graph for this function:

char* ctime64_r ( const Time64_T ytime,
char *  result 
)

Definition at line 863 of file time64.c.

References asctime64_r(), localtime64_r(), memset(), and TM.

Here is the call graph for this function:

struct TM* localtime64 ( const Time64_T ytime)

Definition at line 873 of file time64.c.

References localtime64_r().

Referenced by ctime64().

Here is the call graph for this function:

struct TM* gmtime64 ( const Time64_T ytime)

Definition at line 878 of file time64.c.

References gmtime64_r().

Referenced by bu_utctime().

Here is the call graph for this function:

char* asctime64 ( const struct TM date)

Definition at line 882 of file time64.c.

References asctime64_r().

Referenced by ctime64().

Here is the call graph for this function:

char* ctime64 ( const Time64_T ytime)

Definition at line 886 of file time64.c.

References asctime64(), and localtime64().

Here is the call graph for this function: