Rcpp Version 0.12.14
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 121 of file Date.cpp.

◆ AVGSECSPERYEAR

#define AVGSECSPERYEAR   31556952L

Definition at line 146 of file Date.cpp.

◆ BIGGEST

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

Definition at line 372 of file Date.cpp.

◆ COMPILING_RCPP

#define COMPILING_RCPP

Definition at line 29 of file Date.cpp.

◆ DAY_OF_YEAR

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

Definition at line 418 of file Date.cpp.

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

◆ days_in_year

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

◆ DAYSPERLYEAR

#define DAYSPERLYEAR   366

Definition at line 297 of file Date.cpp.

Referenced by Rcpp::timesub().

◆ DAYSPERNYEAR

#define DAYSPERNYEAR   365

Definition at line 296 of file Date.cpp.

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

◆ DAYSPERWEEK

#define DAYSPERWEEK   7

Definition at line 295 of file Date.cpp.

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

◆ EOVERFLOW

#define EOVERFLOW   79

Definition at line 127 of file Date.cpp.

◆ EPOCH_WDAY

#define EPOCH_WDAY   TM_THURSDAY

Definition at line 326 of file Date.cpp.

Referenced by Rcpp::timesub().

◆ EPOCH_YEAR

#define EPOCH_YEAR   1970

Definition at line 325 of file Date.cpp.

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

◆ gmtptr

#define gmtptr   (&gmtmem)

Definition at line 435 of file Date.cpp.

Referenced by Rcpp::gmtsub().

◆ GRANDPARENTED

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

Definition at line 144 of file Date.cpp.

◆ HOURSPERDAY

#define HOURSPERDAY   24

Definition at line 294 of file Date.cpp.

Referenced by Rcpp::getsecs().

◆ INITIALIZE

#define INITIALIZE (   x)    (x = 0)

Definition at line 150 of file Date.cpp.

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

◆ is_digit

#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().

◆ isleap [1/2]

#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().

◆ isleap [2/2]

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

Definition at line 328 of file Date.cpp.

◆ isleap_sum

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

Definition at line 342 of file Date.cpp.

◆ JULIAN_DAY

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

Definition at line 417 of file Date.cpp.

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

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

Definition at line 155 of file Date.cpp.

◆ MINSPERHOUR

#define MINSPERHOUR   60

Definition at line 293 of file Date.cpp.

Referenced by Rcpp::getsecs().

◆ MINVAL

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

Definition at line 158 of file Date.cpp.

◆ MONSPERYEAR

#define MONSPERYEAR   12

Definition at line 300 of file Date.cpp.

Referenced by Rcpp::getrule().

◆ MONTH_NTH_DAY_OF_WEEK

#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().

◆ MY_TZNAME_MAX

#define MY_TZNAME_MAX   255

Definition at line 378 of file Date.cpp.

◆ OPEN_MODE

#define OPEN_MODE   O_RDONLY

Definition at line 356 of file Date.cpp.

Referenced by Rcpp::tzload().

◆ SECSPERDAY

#define SECSPERDAY   ((int_fast32_t) SECSPERHOUR * HOURSPERDAY)

Definition at line 299 of file Date.cpp.

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

◆ SECSPERHOUR

#define SECSPERHOUR   (SECSPERMIN * MINSPERHOUR)

Definition at line 298 of file Date.cpp.

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

◆ SECSPERMIN

#define SECSPERMIN   60

Definition at line 292 of file Date.cpp.

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

◆ SECSPERREPEAT

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

Definition at line 147 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

◆ SECSPERREPEAT_BITS

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

Definition at line 148 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

◆ TM_APRIL

#define TM_APRIL   3

Definition at line 313 of file Date.cpp.

◆ TM_AUGUST

#define TM_AUGUST   7

Definition at line 317 of file Date.cpp.

◆ TM_DECEMBER

#define TM_DECEMBER   11

Definition at line 321 of file Date.cpp.

◆ TM_FEBRUARY

#define TM_FEBRUARY   1

Definition at line 311 of file Date.cpp.

◆ TM_FRIDAY

#define TM_FRIDAY   5

Definition at line 307 of file Date.cpp.

◆ TM_JANUARY

#define TM_JANUARY   0

Definition at line 310 of file Date.cpp.

◆ TM_JULY

#define TM_JULY   6

Definition at line 316 of file Date.cpp.

◆ TM_JUNE

#define TM_JUNE   5

Definition at line 315 of file Date.cpp.

◆ TM_MARCH

#define TM_MARCH   2

Definition at line 312 of file Date.cpp.

◆ TM_MAY

#define TM_MAY   4

Definition at line 314 of file Date.cpp.

◆ TM_MONDAY

#define TM_MONDAY   1

Definition at line 303 of file Date.cpp.

◆ TM_NOVEMBER

#define TM_NOVEMBER   10

Definition at line 320 of file Date.cpp.

◆ TM_OCTOBER

#define TM_OCTOBER   9

Definition at line 319 of file Date.cpp.

◆ TM_SATURDAY

#define TM_SATURDAY   6

Definition at line 308 of file Date.cpp.

◆ TM_SEPTEMBER

#define TM_SEPTEMBER   8

Definition at line 318 of file Date.cpp.

◆ TM_SUNDAY

#define TM_SUNDAY   0

Definition at line 302 of file Date.cpp.

◆ TM_THURSDAY

#define TM_THURSDAY   4

Definition at line 306 of file Date.cpp.

◆ TM_TUESDAY

#define TM_TUESDAY   2

Definition at line 304 of file Date.cpp.

◆ TM_WEDNESDAY

#define TM_WEDNESDAY   3

Definition at line 305 of file Date.cpp.

◆ TM_YEAR_BASE

#define TM_YEAR_BASE   1900

Definition at line 323 of file Date.cpp.

Referenced by Rcpp::timesub().

◆ TWOS_COMPLEMENT

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

Definition at line 143 of file Date.cpp.

◆ TYPE_BIT

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

Definition at line 140 of file Date.cpp.

Referenced by Rcpp::differ_by_repeat().

◆ TYPE_INTEGRAL

#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().

◆ TYPE_SIGNED

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

◆ TZ_MAGIC

#define TZ_MAGIC   "TZif"

Definition at line 204 of file Date.cpp.

◆ TZ_MAX_CHARS

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

Definition at line 284 of file Date.cpp.

Referenced by Rcpp::tzload().

◆ TZ_MAX_LEAPS

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

Definition at line 289 of file Date.cpp.

Referenced by Rcpp::tzload().

◆ TZ_MAX_TIMES

#define TZ_MAX_TIMES   1200

Definition at line 266 of file Date.cpp.

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

◆ TZ_MAX_TYPES

#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().

◆ TZDEFAULT

#define TZDEFAULT   "localtime"

Definition at line 193 of file Date.cpp.

Referenced by Rcpp::tzload().

◆ TZDEFRULES

#define TZDEFRULES   "America/New_York"

Definition at line 197 of file Date.cpp.

Referenced by Rcpp::tzparse().

◆ TZDEFRULESTRING

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

Definition at line 369 of file Date.cpp.

Referenced by Rcpp::tzparse().

◆ TZDIR

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

Definition at line 189 of file Date.cpp.

◆ TZFILE_H

#define TZFILE_H

Definition at line 169 of file Date.cpp.

◆ YEARSPERREPEAT

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

Definition at line 145 of file Date.cpp.

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