Rcpp Version 0.12.12
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

#define _NO_OLDNAMES   /* avoid tznames */

Definition at line 121 of file Date.cpp.

#define AVGSECSPERYEAR   31556952L

Definition at line 146 of file Date.cpp.

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

Definition at line 372 of file Date.cpp.

#define COMPILING_RCPP

Definition at line 29 of file Date.cpp.

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

Definition at line 418 of file Date.cpp.

Referenced by Rcpp::getrule(), and Rcpp::transtime().

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

Definition at line 297 of file Date.cpp.

Referenced by Rcpp::timesub().

#define DAYSPERNYEAR   365

Definition at line 296 of file Date.cpp.

Referenced by Rcpp::getrule(), and Rcpp::timesub().

#define DAYSPERWEEK   7

Definition at line 295 of file Date.cpp.

Referenced by Rcpp::getrule(), Rcpp::getsecs(), Rcpp::timesub(), and Rcpp::transtime().

#define EOVERFLOW   79

Definition at line 127 of file Date.cpp.

#define EPOCH_WDAY   TM_THURSDAY

Definition at line 326 of file Date.cpp.

Referenced by Rcpp::timesub().

#define EPOCH_YEAR   1970

Definition at line 325 of file Date.cpp.

Referenced by Rcpp::timesub(), and Rcpp::tzparse().

#define gmtptr   (&gmtmem)

Definition at line 435 of file Date.cpp.

Referenced by Rcpp::gmtsub().

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

Definition at line 144 of file Date.cpp.

#define HOURSPERDAY   24

Definition at line 294 of file Date.cpp.

Referenced by Rcpp::getsecs().

#define INITIALIZE (   x)    (x = 0)

Definition at line 150 of file Date.cpp.

Referenced by Rcpp::transtime(), and Rcpp::tzparse().

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

Definition at line 149 of file Date.cpp.

Referenced by Rcpp::getnum(), Rcpp::getrule(), and Rcpp::getzname().

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

Definition at line 328 of file Date.cpp.

Referenced by Rcpp::timesub(), Rcpp::transtime(), and Rcpp::tzparse().

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

Definition at line 328 of file Date.cpp.

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

Definition at line 342 of file Date.cpp.

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

Definition at line 417 of file Date.cpp.

Referenced by Rcpp::getrule(), and Rcpp::transtime().

#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:141

Definition at line 155 of file Date.cpp.

#define MINSPERHOUR   60

Definition at line 293 of file Date.cpp.

Referenced by Rcpp::getsecs().

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

Definition at line 158 of file Date.cpp.

#define MONSPERYEAR   12

Definition at line 300 of file Date.cpp.

Referenced by Rcpp::getrule().

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

Definition at line 419 of file Date.cpp.

Referenced by Rcpp::getrule(), and Rcpp::transtime().

#define MY_TZNAME_MAX   255

Definition at line 378 of file Date.cpp.

#define OPEN_MODE   O_RDONLY

Definition at line 356 of file Date.cpp.

Referenced by Rcpp::tzload().

#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)

Definition at line 299 of file Date.cpp.

Referenced by Rcpp::timesub(), Rcpp::transtime(), and Rcpp::tzparse().

#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)

Definition at line 298 of file Date.cpp.

Referenced by Rcpp::getrule(), Rcpp::getsecs(), Rcpp::timesub(), and Rcpp::tzparse().

#define SECSPERMIN   60

Definition at line 292 of file Date.cpp.

Referenced by Rcpp::getsecs(), and Rcpp::timesub().

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

Definition at line 147 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

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

Definition at line 148 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

#define TM_APRIL   3

Definition at line 313 of file Date.cpp.

#define TM_AUGUST   7

Definition at line 317 of file Date.cpp.

#define TM_DECEMBER   11

Definition at line 321 of file Date.cpp.

#define TM_FEBRUARY   1

Definition at line 311 of file Date.cpp.

#define TM_FRIDAY   5

Definition at line 307 of file Date.cpp.

#define TM_JANUARY   0

Definition at line 310 of file Date.cpp.

#define TM_JULY   6

Definition at line 316 of file Date.cpp.

#define TM_JUNE   5

Definition at line 315 of file Date.cpp.

#define TM_MARCH   2

Definition at line 312 of file Date.cpp.

#define TM_MAY   4

Definition at line 314 of file Date.cpp.

#define TM_MONDAY   1

Definition at line 303 of file Date.cpp.

#define TM_NOVEMBER   10

Definition at line 320 of file Date.cpp.

#define TM_OCTOBER   9

Definition at line 319 of file Date.cpp.

#define TM_SATURDAY   6

Definition at line 308 of file Date.cpp.

#define TM_SEPTEMBER   8

Definition at line 318 of file Date.cpp.

#define TM_SUNDAY   0

Definition at line 302 of file Date.cpp.

#define TM_THURSDAY   4

Definition at line 306 of file Date.cpp.

#define TM_TUESDAY   2

Definition at line 304 of file Date.cpp.

#define TM_WEDNESDAY   3

Definition at line 305 of file Date.cpp.

#define TM_YEAR_BASE   1900

Definition at line 323 of file Date.cpp.

Referenced by Rcpp::timesub().

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

Definition at line 143 of file Date.cpp.

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

Definition at line 140 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

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

Definition at line 142 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat(), and Rcpp::tzload().

#define TYPE_SIGNED (   type)    (((type) -1) < 0)
#define TZ_MAGIC   "TZif"

Definition at line 204 of file Date.cpp.

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

Definition at line 284 of file Date.cpp.

Referenced by Rcpp::tzload().

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

Definition at line 289 of file Date.cpp.

Referenced by Rcpp::tzload().

#define TZ_MAX_TIMES   1200

Definition at line 266 of file Date.cpp.

Referenced by Rcpp::tzload(), and Rcpp::tzparse().

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

Definition at line 271 of file Date.cpp.

Referenced by Rcpp::tzload().

#define TZDEFAULT   "localtime"

Definition at line 193 of file Date.cpp.

Referenced by Rcpp::tzload().

#define TZDEFRULES   "America/New_York"

Definition at line 197 of file Date.cpp.

Referenced by Rcpp::tzparse().

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

Definition at line 369 of file Date.cpp.

Referenced by Rcpp::tzparse().

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

Definition at line 189 of file Date.cpp.

#define TZFILE_H

Definition at line 169 of file Date.cpp.

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

Definition at line 145 of file Date.cpp.

Referenced by Rcpp::tzload(), and Rcpp::tzparse().