TZ-Lib  $VERSION$
localtime.c File Reference
#include "private.h"
#include "tzfile.h"
#include "fcntl.h"

Classes

union  input_buffer
 
union  local_storage
 
struct  lsinfo
 
struct  rule
 
struct  state
 
struct  ttinfo
 

Macros

#define BIGGEST(a, b)   (((a) > (b)) ? (a) : (b))
 
#define gmtptr   (&gmtmem)
 
#define lclptr   (&lclmem)
 
#define LOCALTIME_IMPLEMENTATION
 
#define MY_TZNAME_MAX   255
 
#define NETBSD_INSPIRED_EXTERN
 
#define OPEN_MODE   O_RDONLY
 
#define SMALLEST(a, b)   (((a) < (b)) ? (a) : (b))
 
#define TZ_ABBR_CHAR_SET   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
 
#define TZ_ABBR_ERR_CHAR   '_'
 
#define TZ_ABBR_MAX_LEN   16
 
#define TZ_STRLEN_MAX   255
 
#define TZDEFRULESTRING   ",M4.1.0,M10.5.0"
 
#define WILDABBR   " "
 
#define WRONG   (-1)
 

Enumerations

enum  r_type { JULIAN_DAY, DAY_OF_YEAR, MONTH_NTH_DAY_OF_WEEK }
 

Functions

char * ctime (const time_t *timep)
 
char * ctime_r (const time_t *timep, char *buf)
 
static int_fast32_t detzcode (const char *const codep)
 
static int_fast64_t detzcode64 (const char *const codep)
 
static bool differ_by_repeat (const time_t t1, const time_t t0)
 
static const char * getnum (register const char *strp, int *const nump, const int min, const int max)
 
static const char * getoffset (register const char *strp, int_fast32_t *const offsetp)
 
static const char *ATTRIBUTE_PURE getqzname (register const char *strp, const int delim)
 
static const char * getrule (const char *strp, register struct rule *const rulep)
 
static const char * getsecs (register const char *strp, int_fast32_t *const secsp)
 
static const char *ATTRIBUTE_PURE getzname (register const char *strp)
 
static void gmtcheck (void)
 
struct tmgmtime (const time_t *timep)
 
struct tmgmtime_r (const time_t *timep, struct tm *tmp)
 
static void gmtload (struct state *const sp)
 
static struct tmgmtsub (struct state const *, time_t const *, int_fast32_t, struct tm *)
 
static bool increment_overflow (int *, int)
 
static bool increment_overflow32 (int_fast32_t *const lp, int const m)
 
static bool increment_overflow_time (time_t *, int_fast32_t)
 
static void init_ttinfo (struct ttinfo *s, int_fast32_t gmtoff, bool isdst, int abbrind)
 
static int ATTRIBUTE_PURE leaps_thru_end_of (register const int y)
 
static struct tmlocalsub (struct state const *sp, time_t const *timep, int_fast32_t setname, struct tm *const tmp)
 
struct tmlocaltime (const time_t *timep)
 
struct tmlocaltime_r (const time_t *timep, struct tm *tmp)
 
struct tmlocaltime_rz (struct state *sp, time_t const *timep, struct tm *tmp)
 
static struct tmlocaltime_tzset (time_t const *timep, struct tm *tmp, bool setname)
 
static int lock (void)
 
time_t mktime (struct tm *tmp)
 
static time_t mktime_tzname (struct state *sp, struct tm *tmp, bool setname)
 
time_t mktime_z (struct state *sp, struct tm *tmp)
 
static bool normalize_overflow (int *const tensptr, int *const unitsptr, const int base)
 
static bool normalize_overflow32 (int_fast32_t *, int *, int)
 
static void scrub_abbrs (struct state *sp)
 
static void settzname (void)
 
static time_t time1 (struct tm *const tmp, struct tm *(*funcp)(struct state const *, time_t const *, int_fast32_t, struct tm *), struct state const *sp, const int_fast32_t offset)
 
static time_t time2 (struct tm *const tmp, struct tm *(*funcp)(struct state const *, time_t const *, int_fast32_t, struct tm *), struct state const *sp, const int_fast32_t offset, bool *okayp)
 
static time_t time2sub (struct tm *const tmp, struct tm *(*funcp)(struct state const *, time_t const *, int_fast32_t, struct tm *), struct state const *sp, const int_fast32_t offset, bool *okayp, bool do_norm_secs)
 
static struct tmtimesub (time_t const *, int_fast32_t, struct state const *, struct tm *)
 
static int tmcomp (register const struct tm *const atmp, register const struct tm *const btmp)
 
static int_fast32_t ATTRIBUTE_PURE transtime (const int year, register const struct rule *const rulep, const int_fast32_t offset)
 
static bool typesequiv (struct state const *, int, int)
 
timezone_t tzalloc (char const *name)
 
void tzfree (timezone_t sp)
 
static int tzload (char const *name, struct state *sp, bool doextend)
 
static int tzloadbody (char const *name, struct state *sp, bool doextend, union local_storage *lsp)
 
static bool tzparse (char const *, struct state *, bool)
 
void tzset (void)
 
static void tzset_unlocked (void)
 
static void tzsetlcl (char const *name)
 
static void unlock (void)
 
static void update_tzname_etc (struct state const *sp, struct ttinfo const *ttisp)
 
static int zoneinit (struct state *sp, char const *name)
 

Variables

static const char gmt [] = "GMT"
 
static struct state gmtmem
 
static int lcl_is_set
 
static char lcl_TZname [TZ_STRLEN_MAX+1]
 
static struct state lclmem
 
static const int mon_lengths [2][MONSPERYEAR]
 
static struct tm tm
 
static const char wildabbr [] = WILDABBR
 
static const int year_lengths [2]
 

Macro Definition Documentation

#define BIGGEST (   a,
 
)    (((a) > (b)) ? (a) : (b))

Referenced by time2sub().

#define gmtptr   (&gmtmem)
#define lclptr   (&lclmem)

Referenced by settzname(), and tzsetlcl().

#define LOCALTIME_IMPLEMENTATION
#define MY_TZNAME_MAX   255
#define NETBSD_INSPIRED_EXTERN
#define OPEN_MODE   O_RDONLY

Referenced by tzloadbody().

#define SMALLEST (   a,
 
)    (((a) < (b)) ? (a) : (b))

Referenced by time2sub().

#define TZ_ABBR_CHAR_SET   "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"

Referenced by scrub_abbrs().

#define TZ_ABBR_ERR_CHAR   '_'

Referenced by scrub_abbrs().

#define TZ_ABBR_MAX_LEN   16

Referenced by scrub_abbrs().

#define TZ_STRLEN_MAX   255
#define TZDEFRULESTRING   ",M4.1.0,M10.5.0"

Referenced by tzparse().

#define WILDABBR   " "
#define WRONG   (-1)

Referenced by time1(), and time2sub().

Enumeration Type Documentation

enum r_type
Enumerator
JULIAN_DAY 
DAY_OF_YEAR 
MONTH_NTH_DAY_OF_WEEK 

Function Documentation

char* ctime ( const time_t *  timep)

References asctime(), localtime(), and tm.

char* ctime_r ( const time_t *  timep,
char *  buf 
)

References asctime_r(), localtime_r(), and tm.

static int_fast32_t detzcode ( const char *const  codep)
static

References TWOS_COMPLEMENT.

Referenced by tzloadbody().

static int_fast64_t detzcode64 ( const char *const  codep)
static

References int_fast64_t, TWOS_COMPLEMENT, and uint_fast64_t.

Referenced by tzloadbody().

static bool differ_by_repeat ( const time_t  t1,
const time_t  t0 
)
static
static const char* getnum ( register const char *  strp,
int *const  nump,
const int  min,
const int  max 
)
static

References is_digit.

Referenced by getrule(), and getsecs().

static const char* getoffset ( register const char *  strp,
int_fast32_t *const  offsetp 
)
static

References getsecs().

Referenced by getrule(), and tzparse().

static const char* ATTRIBUTE_PURE getqzname ( register const char *  strp,
const int  delim 
)
static

Referenced by tzparse().

static const char* getrule ( const char *  strp,
register struct rule *const  rulep 
)
static
static const char* getsecs ( register const char *  strp,
int_fast32_t *const  secsp 
)
static
static const char* ATTRIBUTE_PURE getzname ( register const char *  strp)
static

References is_digit.

Referenced by tzparse().

static void gmtcheck ( void  )
static

References gmtload(), lock(), and unlock().

Referenced by gmtime_r(), and mktime_tzname().

struct tm* gmtime ( const time_t *  timep)

References gmtime_r(), and tm.

struct tm* gmtime_r ( const time_t *  timep,
struct tm tmp 
)

References gmtcheck(), and gmtsub().

Referenced by gmtime(), and my_gmtime_r().

static void gmtload ( struct state *const  sp)
static

References gmt, tzload(), and tzparse().

Referenced by gmtcheck().

static struct tm * gmtsub ( struct state const *  sp,
time_t const *  timep,
int_fast32_t  offset,
struct tm tmp 
)
static

References state::chars, gmt, timesub(), tm, and wildabbr.

Referenced by gmtime_r(), localsub(), and mktime_tzname().

static bool increment_overflow ( int *  ip,
int  j 
)
static
static bool increment_overflow32 ( int_fast32_t *const  lp,
int const  m 
)
static

References INT_FAST32_MAX, and INT_FAST32_MIN.

Referenced by normalize_overflow32(), and time2sub().

static bool increment_overflow_time ( time_t *  tp,
int_fast32_t  j 
)
static

References time_t_max, time_t_min, and TYPE_SIGNED.

Referenced by time2sub(), and tzparse().

static void init_ttinfo ( struct ttinfo s,
int_fast32_t  gmtoff,
bool  isdst,
int  abbrind 
)
static
static int ATTRIBUTE_PURE leaps_thru_end_of ( register const int  y)
static

Referenced by timesub().

struct tm* localtime ( const time_t *  timep)

References localtime_tzset(), and tm.

Referenced by ctime(), display(), and localtime_r().

struct tm* localtime_r ( const time_t *  timep,
struct tm tmp 
)

References localtime_tzset().

Referenced by ctime_r().

struct tm* localtime_rz ( struct state sp,
time_t const *  timep,
struct tm tmp 
)

References localsub().

static struct tm* localtime_tzset ( time_t const *  timep,
struct tm tmp,
bool  setname 
)
static

References localsub(), lock(), tzset_unlocked(), and unlock().

Referenced by localtime(), and localtime_r().

static int lock ( void  )
static
time_t mktime ( struct tm tmp)

References lock(), mktime_tzname(), tzset_unlocked(), and unlock().

Referenced by _fmt().

static time_t mktime_tzname ( struct state sp,
struct tm tmp,
bool  setname 
)
static

References gmtcheck(), gmtsub(), localsub(), and time1().

Referenced by mktime(), and mktime_z().

time_t mktime_z ( struct state sp,
struct tm tmp 
)

References mktime_tzname().

static bool normalize_overflow ( int *const  tensptr,
int *const  unitsptr,
const int  base 
)
static

References increment_overflow().

Referenced by time2sub().

static bool normalize_overflow32 ( int_fast32_t tensptr,
int *  unitsptr,
int  base 
)
static

References increment_overflow32().

Referenced by time2sub().

static void scrub_abbrs ( struct state sp)
static
static void settzname ( void  )
static
static time_t time1 ( struct tm *const  tmp,
struct tm *(*)(struct state const *, time_t const *, int_fast32_t, struct tm *)  funcp,
struct state const *  sp,
const int_fast32_t  offset 
)
static
static time_t time2 ( struct tm *const  tmp,
struct tm *(*)(struct state const *, time_t const *, int_fast32_t, struct tm *)  funcp,
struct state const *  sp,
const int_fast32_t  offset,
bool okayp 
)
static

References time2sub().

Referenced by time1().

static time_t time2sub ( struct tm *const  tmp,
struct tm *(*)(struct state const *, time_t const *, int_fast32_t, struct tm *)  funcp,
struct state const *  sp,
const int_fast32_t  offset,
bool okayp,
bool  do_norm_secs 
)
static
static struct tm * timesub ( time_t const *  timep,
int_fast32_t  offset,
struct state const *  sp,
struct tm tmp 
)
static
static int tmcomp ( register const struct tm *const  atmp,
register const struct tm *const  btmp 
)
static

Referenced by time2sub().

static int_fast32_t ATTRIBUTE_PURE transtime ( const int  year,
register const struct rule *const  rulep,
const int_fast32_t  offset 
)
static
static bool typesequiv ( struct state const *  sp,
int  a,
int  b 
)
static
timezone_t tzalloc ( char const *  name)

References zoneinit().

void tzfree ( timezone_t  sp)
static int tzload ( char const *  name,
struct state sp,
bool  doextend 
)
static

References tzloadbody().

Referenced by gmtload(), tzparse(), and zoneinit().

void tzset ( void  )

References lock(), tzset_unlocked(), and unlock().

Referenced by strftime(), and tzalloc().

static void tzset_unlocked ( void  )
static

References tzsetlcl().

Referenced by localtime_tzset(), mktime(), and tzset().

static void tzsetlcl ( char const *  name)
static

References lclptr, settzname(), and zoneinit().

Referenced by tzset_unlocked().

static void unlock ( void  )
static
static void update_tzname_etc ( struct state const *  sp,
struct ttinfo const *  ttisp 
)
static
static int zoneinit ( struct state sp,
char const *  name 
)
static

Variable Documentation

const char gmt[] = "GMT"
static
struct state gmtmem
static
int lcl_is_set
static
char lcl_TZname[TZ_STRLEN_MAX+1]
static
struct state lclmem
static
const int mon_lengths[2][MONSPERYEAR]
static
Initial value:
= {
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
}
const char wildabbr[] = WILDABBR
static

Referenced by gmtsub(), and settzname().

const int year_lengths[2]
static
Initial value:
= {
}
#define DAYSPERLYEAR
Definition: db/tzfile.h:122
#define DAYSPERNYEAR
Definition: db/tzfile.h:121