Rcpp Version 1.0.9
date.cpp File Reference
#include <Rcpp.h>
#include <time.h>
#include <Rcpp/exceptions.h>
#include "sys/types.h"
#include "string.h"
#include "limits.h"
#include <errno.h>
#include "stdlib.h"
#include "stdint.h"
#include "stdio.h"
#include "fcntl.h"
#include "float.h"
#include <unistd.h>
Include dependency graph for date.cpp:

Go to the source code of this file.

Classes

struct  Rcpp::tzhead
 
struct  Rcpp::ttinfo
 
struct  Rcpp::lsinfo
 
struct  Rcpp::state
 
struct  Rcpp::rule
 

Namespaces

 Rcpp
 Rcpp API.
 

Macros

#define COMPILING_RCPP
 
#define isleap(y)   ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
 
#define days_in_year(year)   (isleap(year) ? 366 : 365)
 
#define _NO_OLDNAMES   /* avoid tznames */
 
#define EOVERFLOW   79
 
#define TYPE_BIT(type)   (sizeof (type) * CHAR_BIT)
 
#define TYPE_SIGNED(type)   (((type) -1) < 0)
 
#define TYPE_INTEGRAL(type)   (((type) 0.5) != 0.5)
 
#define TWOS_COMPLEMENT(t)   ((t) ~ (t) 0 < 0)
 
#define GRANDPARENTED   "Local time zone must be set--see zic manual page"
 
#define YEARSPERREPEAT   400 /* years before a Gregorian repeat */
 
#define AVGSECSPERYEAR   31556952L
 
#define SECSPERREPEAT   ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
 
#define SECSPERREPEAT_BITS   34 /* ceil(log2(SECSPERREPEAT)) */
 
#define is_digit(c)   ((unsigned)(c) - '0' <= 9)
 
#define INITIALIZE(x)   (x = 0)
 
#define MAXVAL(t, b)
 
#define MINVAL(t, b)    ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))
 
#define TZFILE_H
 
#define TZDIR   "/usr/local/etc/zoneinfo" /* Time zone object file directory */
 
#define TZDEFAULT   "localtime"
 
#define TZDEFRULES   "America/New_York"
 
#define TZ_MAGIC   "TZif"
 
#define TZ_MAX_TIMES   1200
 
#define TZ_MAX_TYPES   256 /* Limited by what (unsigned char)'s can hold */
 
#define TZ_MAX_CHARS   100 /* Maximum number of abbreviation characters */
 
#define TZ_MAX_LEAPS   50 /* Maximum number of leap second corrections */
 
#define SECSPERMIN   60
 
#define MINSPERHOUR   60
 
#define HOURSPERDAY   24
 
#define DAYSPERWEEK   7
 
#define DAYSPERNYEAR   365
 
#define DAYSPERLYEAR   366
 
#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)
 
#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)
 
#define MONSPERYEAR   12
 
#define TM_SUNDAY   0
 
#define TM_MONDAY   1
 
#define TM_TUESDAY   2
 
#define TM_WEDNESDAY   3
 
#define TM_THURSDAY   4
 
#define TM_FRIDAY   5
 
#define TM_SATURDAY   6
 
#define TM_JANUARY   0
 
#define TM_FEBRUARY   1
 
#define TM_MARCH   2
 
#define TM_APRIL   3
 
#define TM_MAY   4
 
#define TM_JUNE   5
 
#define TM_JULY   6
 
#define TM_AUGUST   7
 
#define TM_SEPTEMBER   8
 
#define TM_OCTOBER   9
 
#define TM_NOVEMBER   10
 
#define TM_DECEMBER   11
 
#define TM_YEAR_BASE   1900
 
#define EPOCH_YEAR   1970
 
#define EPOCH_WDAY   TM_THURSDAY
 
#define isleap(y)   (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
 
#define isleap_sum(a, b)   isleap((a) % 400 + (b) % 400)
 
#define OPEN_MODE   O_RDONLY
 
#define TZDEFRULESTRING   ",M4.1.0,M10.5.0"
 
#define BIGGEST(a, b)   (((a) > (b)) ? (a) : (b))
 
#define MY_TZNAME_MAX   255
 
#define JULIAN_DAY   0 /* Jn - Julian day */
 
#define DAY_OF_YEAR   1 /* n - day of year */
 
#define MONTH_NTH_DAY_OF_WEEK   2 /* Mm.n.d - month, week, day of week */
 
#define gmtptr   (&gmtmem)
 

Functions

attribute_hidden double Rcpp::mktime00 (struct tm &tm)
 
static int Rcpp::tzparse (const char *name, struct state *sp, int lastditch)
 
static int Rcpp::typesequiv (const struct state *sp, int a, int b)
 
static const char * Rcpp::getsecs (const char *strp, int_fast32_t *secsp)
 
static const char * Rcpp::getnum (const char *strp, int *const nump, const int min, const int max)
 
static const char * Rcpp::getrule (const char *strp, struct rule *const rulep)
 
static int_fast32_t Rcpp::transtime (int year, const struct rule *rulep, int_fast32_t offset)
 
static struct tm * Rcpp::timesub (const time_t *timep, int_fast32_t offset, const struct state *sp, struct tm *tmp)
 
static int Rcpp::leaps_thru_end_of (const int y)
 
static int Rcpp::increment_overflow (int *const ip, int j)
 
static int Rcpp::increment_overflow_time (time_t *tp, int_fast32_t j)
 
static int_fast32_t Rcpp::detzcode (const char *const codep)
 
static int_fast64_t Rcpp::detzcode64 (const char *const codep)
 
static int Rcpp::differ_by_repeat (const time_t t1, const time_t t0)
 
static const char * Rcpp::getzname (const char *strp)
 
static const char * Rcpp::getqzname (const char *strp, const int delim)
 
static const char * Rcpp::getoffset (const char *strp, int_fast32_t *const offsetp)
 
static int Rcpp::tzload (const char *name, struct state *const sp, const int doextend)
 
static void Rcpp::gmtload (struct state *const sp)
 
static struct tm * Rcpp::gmtsub (const time_t *const timep, const int_fast32_t offset, struct tm *const tmp)
 
attribute_hidden struct tm * Rcpp::gmtime_ (const time_t *const x)
 

Variables

static time_t const Rcpp::time_t_min = MINVAL(time_t, TYPE_BIT(time_t))
 
static time_t const Rcpp::time_t_max = MAXVAL(time_t, TYPE_BIT(time_t))
 
static const char Rcpp::gmt [] = "GMT"
 
static const int Rcpp::mon_lengths [2][MONSPERYEAR]
 
static const int Rcpp::year_lengths [2]
 
static int Rcpp::gmt_is_set
 
static struct state Rcpp::gmtmem
 
static struct tm Rcpp::tm
 

Macro Definition Documentation

◆ _NO_OLDNAMES

#define _NO_OLDNAMES   /* avoid tznames */

Definition at line 120 of file date.cpp.

◆ AVGSECSPERYEAR

#define AVGSECSPERYEAR   31556952L

Definition at line 145 of file date.cpp.

◆ BIGGEST

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

Definition at line 371 of file date.cpp.

◆ COMPILING_RCPP

#define COMPILING_RCPP

Definition at line 28 of file date.cpp.

◆ DAY_OF_YEAR

#define DAY_OF_YEAR   1 /* n - day of year */

Definition at line 417 of file date.cpp.

◆ days_in_year

#define days_in_year (   year)    (isleap(year) ? 366 : 365)

◆ DAYSPERLYEAR

#define DAYSPERLYEAR   366

Definition at line 296 of file date.cpp.

◆ DAYSPERNYEAR

#define DAYSPERNYEAR   365

Definition at line 295 of file date.cpp.

◆ DAYSPERWEEK

#define DAYSPERWEEK   7

Definition at line 294 of file date.cpp.

◆ EOVERFLOW

#define EOVERFLOW   79

Definition at line 126 of file date.cpp.

◆ EPOCH_WDAY

#define EPOCH_WDAY   TM_THURSDAY

Definition at line 325 of file date.cpp.

◆ EPOCH_YEAR

#define EPOCH_YEAR   1970

Definition at line 324 of file date.cpp.

◆ gmtptr

#define gmtptr   (&gmtmem)

Definition at line 434 of file date.cpp.

◆ GRANDPARENTED

#define GRANDPARENTED   "Local time zone must be set--see zic manual page"

Definition at line 143 of file date.cpp.

◆ HOURSPERDAY

#define HOURSPERDAY   24

Definition at line 293 of file date.cpp.

◆ INITIALIZE

#define INITIALIZE (   x)    (x = 0)

Definition at line 149 of file date.cpp.

◆ is_digit

#define is_digit (   c)    ((unsigned)(c) - '0' <= 9)

Definition at line 148 of file date.cpp.

◆ isleap [1/2]

#define isleap (   y)    ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)

Definition at line 327 of file date.cpp.

◆ isleap [2/2]

#define isleap (   y)    (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))

Definition at line 327 of file date.cpp.

◆ isleap_sum

#define isleap_sum (   a,
 
)    isleap((a) % 400 + (b) % 400)

Definition at line 341 of file date.cpp.

◆ JULIAN_DAY

#define JULIAN_DAY   0 /* Jn - Julian day */

Definition at line 416 of file date.cpp.

◆ MAXVAL

#define MAXVAL (   t,
 
)
Value:
((t) (((t) 1 << ((b) - 1 - TYPE_SIGNED(t))) \
- 1 + ((t) 1 << ((b) - 1 - TYPE_SIGNED(t)))))
#define TYPE_SIGNED(type)
Definition: date.cpp:140

Definition at line 154 of file date.cpp.

◆ MINSPERHOUR

#define MINSPERHOUR   60

Definition at line 292 of file date.cpp.

◆ MINVAL

#define MINVAL (   t,
 
)     ((t) (TYPE_SIGNED(t) ? - TWOS_COMPLEMENT(t) - MAXVAL(t, b) : 0))

Definition at line 157 of file date.cpp.

◆ MONSPERYEAR

#define MONSPERYEAR   12

Definition at line 299 of file date.cpp.

◆ MONTH_NTH_DAY_OF_WEEK

#define MONTH_NTH_DAY_OF_WEEK   2 /* Mm.n.d - month, week, day of week */

Definition at line 418 of file date.cpp.

◆ MY_TZNAME_MAX

#define MY_TZNAME_MAX   255

Definition at line 377 of file date.cpp.

◆ OPEN_MODE

#define OPEN_MODE   O_RDONLY

Definition at line 355 of file date.cpp.

◆ SECSPERDAY

#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)

Definition at line 298 of file date.cpp.

◆ SECSPERHOUR

#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)

Definition at line 297 of file date.cpp.

◆ SECSPERMIN

#define SECSPERMIN   60

Definition at line 291 of file date.cpp.

◆ SECSPERREPEAT

#define SECSPERREPEAT   ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)

Definition at line 146 of file date.cpp.

◆ SECSPERREPEAT_BITS

#define SECSPERREPEAT_BITS   34 /* ceil(log2(SECSPERREPEAT)) */

Definition at line 147 of file date.cpp.

◆ TM_APRIL

#define TM_APRIL   3

Definition at line 312 of file date.cpp.

◆ TM_AUGUST

#define TM_AUGUST   7

Definition at line 316 of file date.cpp.

◆ TM_DECEMBER

#define TM_DECEMBER   11

Definition at line 320 of file date.cpp.

◆ TM_FEBRUARY

#define TM_FEBRUARY   1

Definition at line 310 of file date.cpp.

◆ TM_FRIDAY

#define TM_FRIDAY   5

Definition at line 306 of file date.cpp.

◆ TM_JANUARY

#define TM_JANUARY   0

Definition at line 309 of file date.cpp.

◆ TM_JULY

#define TM_JULY   6

Definition at line 315 of file date.cpp.

◆ TM_JUNE

#define TM_JUNE   5

Definition at line 314 of file date.cpp.

◆ TM_MARCH

#define TM_MARCH   2

Definition at line 311 of file date.cpp.

◆ TM_MAY

#define TM_MAY   4

Definition at line 313 of file date.cpp.

◆ TM_MONDAY

#define TM_MONDAY   1

Definition at line 302 of file date.cpp.

◆ TM_NOVEMBER

#define TM_NOVEMBER   10

Definition at line 319 of file date.cpp.

◆ TM_OCTOBER

#define TM_OCTOBER   9

Definition at line 318 of file date.cpp.

◆ TM_SATURDAY

#define TM_SATURDAY   6

Definition at line 307 of file date.cpp.

◆ TM_SEPTEMBER

#define TM_SEPTEMBER   8

Definition at line 317 of file date.cpp.

◆ TM_SUNDAY

#define TM_SUNDAY   0

Definition at line 301 of file date.cpp.

◆ TM_THURSDAY

#define TM_THURSDAY   4

Definition at line 305 of file date.cpp.

◆ TM_TUESDAY

#define TM_TUESDAY   2

Definition at line 303 of file date.cpp.

◆ TM_WEDNESDAY

#define TM_WEDNESDAY   3

Definition at line 304 of file date.cpp.

◆ TM_YEAR_BASE

#define TM_YEAR_BASE   1900

Definition at line 322 of file date.cpp.

◆ TWOS_COMPLEMENT

#define TWOS_COMPLEMENT (   t)    ((t) ~ (t) 0 < 0)

Definition at line 142 of file date.cpp.

◆ TYPE_BIT

#define TYPE_BIT (   type)    (sizeof (type) * CHAR_BIT)

Definition at line 139 of file date.cpp.

◆ TYPE_INTEGRAL

#define TYPE_INTEGRAL (   type)    (((type) 0.5) != 0.5)

Definition at line 141 of file date.cpp.

◆ TYPE_SIGNED

#define TYPE_SIGNED (   type)    (((type) -1) < 0)

Definition at line 140 of file date.cpp.

◆ TZ_MAGIC

#define TZ_MAGIC   "TZif"

Definition at line 203 of file date.cpp.

◆ TZ_MAX_CHARS

#define TZ_MAX_CHARS   100 /* Maximum number of abbreviation characters */

Definition at line 283 of file date.cpp.

◆ TZ_MAX_LEAPS

#define TZ_MAX_LEAPS   50 /* Maximum number of leap second corrections */

Definition at line 288 of file date.cpp.

◆ TZ_MAX_TIMES

#define TZ_MAX_TIMES   1200

Definition at line 265 of file date.cpp.

◆ TZ_MAX_TYPES

#define TZ_MAX_TYPES   256 /* Limited by what (unsigned char)'s can hold */

Definition at line 270 of file date.cpp.

◆ TZDEFAULT

#define TZDEFAULT   "localtime"

Definition at line 192 of file date.cpp.

◆ TZDEFRULES

#define TZDEFRULES   "America/New_York"

Definition at line 196 of file date.cpp.

◆ TZDEFRULESTRING

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

Definition at line 368 of file date.cpp.

◆ TZDIR

#define TZDIR   "/usr/local/etc/zoneinfo" /* Time zone object file directory */

Definition at line 188 of file date.cpp.

◆ TZFILE_H

#define TZFILE_H

Definition at line 168 of file date.cpp.

◆ YEARSPERREPEAT

#define YEARSPERREPEAT   400 /* years before a Gregorian repeat */

Definition at line 144 of file date.cpp.