Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Enumerations | Functions
date_core.c File Reference
#include "ruby.h"
#include "ruby/encoding.h"
#include "ruby/util.h"
#include <math.h>
#include <time.h>
#include <assert.h>
#include "date_tmx.h"
#include <errno.h>

Go to the source code of this file.

Data Structures

struct  SimpleDateData
 
struct  ComplexDateData
 
union  DateData
 

Macros

#define NDEBUG
 
#define USE_PACK
 
#define f_boolcast(x)   ((x) ? Qtrue : Qfalse)
 
#define f_abs(x)   rb_funcall(x, rb_intern("abs"), 0)
 
#define f_negate(x)   rb_funcall(x, rb_intern("-@"), 0)
 
#define f_add(x, y)   rb_funcall(x, '+', 1, y)
 
#define f_sub(x, y)   rb_funcall(x, '-', 1, y)
 
#define f_mul(x, y)   rb_funcall(x, '*', 1, y)
 
#define f_div(x, y)   rb_funcall(x, '/', 1, y)
 
#define f_quo(x, y)   rb_funcall(x, rb_intern("quo"), 1, y)
 
#define f_idiv(x, y)   rb_funcall(x, rb_intern("div"), 1, y)
 
#define f_mod(x, y)   rb_funcall(x, '%', 1, y)
 
#define f_remainder(x, y)   rb_funcall(x, rb_intern("remainder"), 1, y)
 
#define f_expt(x, y)   rb_funcall(x, rb_intern("**"), 1, y)
 
#define f_floor(x)   rb_funcall(x, rb_intern("floor"), 0)
 
#define f_ceil(x)   rb_funcall(x, rb_intern("ceil"), 0)
 
#define f_truncate(x)   rb_funcall(x, rb_intern("truncate"), 0)
 
#define f_round(x)   rb_funcall(x, rb_intern("round"), 0)
 
#define f_to_i(x)   rb_funcall(x, rb_intern("to_i"), 0)
 
#define f_to_r(x)   rb_funcall(x, rb_intern("to_r"), 0)
 
#define f_to_s(x)   rb_funcall(x, rb_intern("to_s"), 0)
 
#define f_inspect(x)   rb_funcall(x, rb_intern("inspect"), 0)
 
#define f_add3(x, y, z)   f_add(f_add(x, y), z)
 
#define f_sub3(x, y, z)   f_sub(f_sub(x, y), z)
 
#define f_nonzero_p(x)   (!f_zero_p(x))
 
#define f_positive_p(x)   (!f_negative_p(x))
 
#define f_ajd(x)   rb_funcall(x, rb_intern("ajd"), 0)
 
#define f_jd(x)   rb_funcall(x, rb_intern("jd"), 0)
 
#define f_year(x)   rb_funcall(x, rb_intern("year"), 0)
 
#define f_mon(x)   rb_funcall(x, rb_intern("mon"), 0)
 
#define f_mday(x)   rb_funcall(x, rb_intern("mday"), 0)
 
#define f_wday(x)   rb_funcall(x, rb_intern("wday"), 0)
 
#define f_hour(x)   rb_funcall(x, rb_intern("hour"), 0)
 
#define f_min(x)   rb_funcall(x, rb_intern("min"), 0)
 
#define f_sec(x)   rb_funcall(x, rb_intern("sec"), 0)
 
#define NDIV(x, y)   (-(-((x)+1)/(y))-1)
 
#define NMOD(x, y)   ((y)-(-((x)+1)%(y))-1)
 
#define DIV(n, d)   ((n)<0 ? NDIV((n),(d)) : (n)/(d))
 
#define MOD(n, d)   ((n)<0 ? NMOD((n),(d)) : (n)%(d))
 
#define HAVE_JD   (1 << 0)
 
#define HAVE_DF   (1 << 1)
 
#define HAVE_CIVIL   (1 << 2)
 
#define HAVE_TIME   (1 << 3)
 
#define COMPLEX_DAT   (1 << 7)
 
#define have_jd_p(x)   ((x)->flags & HAVE_JD)
 
#define have_df_p(x)   ((x)->flags & HAVE_DF)
 
#define have_civil_p(x)   ((x)->flags & HAVE_CIVIL)
 
#define have_time_p(x)   ((x)->flags & HAVE_TIME)
 
#define complex_dat_p(x)   ((x)->flags & COMPLEX_DAT)
 
#define simple_dat_p(x)   (!complex_dat_p(x))
 
#define ITALY   2299161 /* 1582-10-15 */
 
#define ENGLAND   2361222 /* 1752-09-14 */
 
#define JULIAN   positive_inf
 
#define GREGORIAN   negative_inf
 
#define DEFAULT_SG   ITALY
 
#define UNIX_EPOCH_IN_CJD   INT2FIX(2440588) /* 1970-01-01 */
 
#define MINUTE_IN_SECONDS   60
 
#define HOUR_IN_SECONDS   3600
 
#define DAY_IN_SECONDS   86400
 
#define SECOND_IN_MILLISECONDS   1000
 
#define SECOND_IN_NANOSECONDS   1000000000
 
#define JC_PERIOD0   1461 /* 365.25 * 4 */
 
#define GC_PERIOD0   146097 /* 365.2425 * 400 */
 
#define CM_PERIOD0   71149239 /* (lcm 7 1461 146097) */
 
#define CM_PERIOD   (0xfffffff / CM_PERIOD0 * CM_PERIOD0)
 
#define CM_PERIOD_JCY   (CM_PERIOD / JC_PERIOD0 * 4)
 
#define CM_PERIOD_GCY   (CM_PERIOD / GC_PERIOD0 * 400)
 
#define REFORM_BEGIN_YEAR   1582
 
#define REFORM_END_YEAR   1930
 
#define REFORM_BEGIN_JD   2298874 /* ns 1582-01-01 */
 
#define REFORM_END_JD   2426355 /* os 1930-12-31 */
 
#define SEC_WIDTH   6
 
#define MIN_WIDTH   6
 
#define HOUR_WIDTH   5
 
#define MDAY_WIDTH   5
 
#define MON_WIDTH   4
 
#define SEC_SHIFT   0
 
#define MIN_SHIFT   SEC_WIDTH
 
#define HOUR_SHIFT   (MIN_WIDTH + SEC_WIDTH)
 
#define MDAY_SHIFT   (HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)
 
#define MON_SHIFT   (MDAY_WIDTH + HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)
 
#define PK_MASK(x)   ((1 << (x)) - 1)
 
#define EX_SEC(x)   (((x) >> SEC_SHIFT) & PK_MASK(SEC_WIDTH))
 
#define EX_MIN(x)   (((x) >> MIN_SHIFT) & PK_MASK(MIN_WIDTH))
 
#define EX_HOUR(x)   (((x) >> HOUR_SHIFT) & PK_MASK(HOUR_WIDTH))
 
#define EX_MDAY(x)   (((x) >> MDAY_SHIFT) & PK_MASK(MDAY_WIDTH))
 
#define EX_MON(x)   (((x) >> MON_SHIFT) & PK_MASK(MON_WIDTH))
 
#define PACK5(m, d, h, min, s)
 
#define PACK2(m, d)   (((m) << MON_SHIFT) | ((d) << MDAY_SHIFT))
 
#define date_sg_t   double
 
#define get_d1(x)
 
#define get_d1a(x)
 
#define get_d1b(x)
 
#define get_d2(x, y)
 
#define set_to_simple(obj, x, _nth, _jd, _sg, _year, _mon, _mday, _flags)
 
#define set_to_complex(obj, x, _nth, _jd, _df, _sf, _of, _sg, _year, _mon, _mday, _hour, _min, _sec, _flags)
 
#define copy_simple_to_complex(obj, x, y)
 
#define copy_complex_to_simple(obj, x, y)
 
#define canonicalize_jd(_nth, _jd)
 
#define HALF_DAYS_IN_SECONDS   (DAY_IN_SECONDS / 2)
 
#define decode_offset(of, s, h, m)
 
#define valid_sg(sg)
 
#define jd_trunc   d_trunc
 
#define k_trunc   d_trunc
 
#define num2num_with_frac(s, n)
 
#define num2int_with_frac(s, n)
 
#define canon24oc()
 
#define add_frac()
 
#define val2sg(vsg, dsg)
 
#define set_hash0(k, v)   rb_hash_aset(hash, k, v)
 
#define ref_hash0(k)   rb_hash_aref(hash, k)
 
#define del_hash0(k)   rb_hash_delete(hash, k)
 
#define set_hash(k, v)   rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
 
#define ref_hash(k)   rb_hash_aref(hash, ID2SYM(rb_intern(k)))
 
#define del_hash(k)   rb_hash_delete(hash, ID2SYM(rb_intern(k)))
 
#define sym(x)   ID2SYM(rb_intern(x))
 
#define val2off(vof, iof)
 
#define SMALLBUF   100
 
#define MILLISECOND_IN_NANOSECONDS   1000000
 
#define f_subsec(x)   rb_funcall(x, rb_intern("subsec"), 0)
 
#define f_utc_offset(x)   rb_funcall(x, rb_intern("utc_offset"), 0)
 
#define f_local3(x, y, m, d)   rb_funcall(x, rb_intern("local"), 3, y, m, d)
 
#define rb_intern(str)   rb_intern_const(str)
 
#define f_public(m, s)
 

Enumerations

enum  { DECIMAL_SIZE_OF_LONG = DECIMAL_SIZE_OF_BITS(CHAR_BIT*sizeof(long)), JISX0301_DATE_SIZE = DECIMAL_SIZE_OF_LONG+8 }
 

Functions

VALUE date_zone_to_diff (VALUE)
 
VALUE date__strptime (const char *str, size_t slen, const char *fmt, size_t flen, VALUE hash)
 
VALUE date__parse (VALUE str, VALUE comp)
 
VALUE date__iso8601 (VALUE)
 
VALUE date__rfc3339 (VALUE)
 
VALUE date__xmlschema (VALUE)
 
VALUE date__rfc2822 (VALUE)
 
VALUE date__httpdate (VALUE)
 
VALUE date__jisx0301 (VALUE)
 
size_t date_strftime (char *s, size_t maxsize, const char *format, const struct tmx *tmx)
 
void Init_date_core (void)
 

Macro Definition Documentation

◆ add_frac

#define add_frac ( )
Value:
{\
if (f_nonzero_p(fr2))\
ret = d_lite_plus(ret, fr2);\
}
#define f_nonzero_p(x)
Definition: date_core.c:125

Definition at line 3237 of file date_core.c.

◆ canon24oc

#define canon24oc ( )
Value:
{\
if (rh == 24) {\
rh = 0;\
fr2 = f_add(fr2, INT2FIX(1));\
}\
}
#define f_add(x, y)
Definition: date_core.c:32
#define INT2FIX(i)
Definition: ruby.h:232

Definition at line 3229 of file date_core.c.

◆ canonicalize_jd

#define canonicalize_jd (   _nth,
  _jd 
)
Value:
{\
if (_jd < 0) {\
_nth = f_sub(_nth, INT2FIX(1));\
_jd += CM_PERIOD;\
}\
if (_jd >= CM_PERIOD) {\
_nth = f_add(_nth, INT2FIX(1));\
_jd -= CM_PERIOD;\
}\
}
#define f_add(x, y)
Definition: date_core.c:32
#define f_sub(x, y)
Definition: date_core.c:33
#define INT2FIX(i)
Definition: ruby.h:232
#define CM_PERIOD
Definition: date_core.c:183

Definition at line 1111 of file date_core.c.

◆ CM_PERIOD

#define CM_PERIOD   (0xfffffff / CM_PERIOD0 * CM_PERIOD0)

Definition at line 183 of file date_core.c.

◆ CM_PERIOD0

#define CM_PERIOD0   71149239 /* (lcm 7 1461 146097) */

Definition at line 182 of file date_core.c.

◆ CM_PERIOD_GCY

#define CM_PERIOD_GCY   (CM_PERIOD / GC_PERIOD0 * 400)

Definition at line 185 of file date_core.c.

◆ CM_PERIOD_JCY

#define CM_PERIOD_JCY   (CM_PERIOD / JC_PERIOD0 * 4)

Definition at line 184 of file date_core.c.

◆ COMPLEX_DAT

#define COMPLEX_DAT   (1 << 7)

Definition at line 157 of file date_core.c.

◆ complex_dat_p

#define complex_dat_p (   x)    ((x)->flags & COMPLEX_DAT)

Definition at line 163 of file date_core.c.

◆ copy_complex_to_simple

#define copy_complex_to_simple (   obj,
  x,
 
)
Value:
{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->sg = (date_sg_t)((y)->sg);\
(x)->year = (y)->year;\
(x)->pc = PACK2(EX_MON((y)->pc), EX_MDAY((y)->pc));\
(x)->flags = (y)->flags;\
}
#define EX_MDAY(x)
Definition: date_core.c:210
#define EX_MON(x)
Definition: date_core.c:211
#define PACK2(m, d)
Definition: date_core.c:217
#define date_sg_t
Definition: date_core.c:228

Definition at line 417 of file date_core.c.

◆ copy_simple_to_complex

#define copy_simple_to_complex (   obj,
  x,
 
)
Value:
{\
RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
(x)->jd = (y)->jd;\
(x)->df = 0;\
RB_OBJ_WRITE((obj), &(x)->sf, INT2FIX(0));\
(x)->of = 0;\
(x)->sg = (date_sg_t)((y)->sg);\
(x)->year = (y)->year;\
(x)->pc = PACK5(EX_MON((y)->pc), EX_MDAY((y)->pc), 0, 0, 0);\
(x)->flags = (y)->flags;\
}
#define PACK5(m, d, h, min, s)
Definition: date_core.c:213
#define EX_MDAY(x)
Definition: date_core.c:210
#define EX_MON(x)
Definition: date_core.c:211
#define date_sg_t
Definition: date_core.c:228
#define INT2FIX(i)
Definition: ruby.h:232

Definition at line 391 of file date_core.c.

◆ date_sg_t

#define date_sg_t   double

Definition at line 228 of file date_core.c.

◆ DAY_IN_SECONDS

#define DAY_IN_SECONDS   86400

Definition at line 176 of file date_core.c.

◆ decode_offset

#define decode_offset (   of,
  s,
  h,
 
)
Value:
{\
int a;\
s = (of < 0) ? '-' : '+';\
a = (of < 0) ? -of : of;\
h = a / HOUR_IN_SECONDS;\
}
#define HOUR_IN_SECONDS
Definition: date_core.c:175
#define MINUTE_IN_SECONDS
Definition: date_core.c:174

Definition at line 1930 of file date_core.c.

◆ DEFAULT_SG

#define DEFAULT_SG   ITALY

Definition at line 170 of file date_core.c.

◆ del_hash

#define del_hash (   k)    rb_hash_delete(hash, ID2SYM(rb_intern(k)))

Definition at line 3684 of file date_core.c.

◆ del_hash0

#define del_hash0 (   k)    rb_hash_delete(hash, k)

Definition at line 3680 of file date_core.c.

◆ DIV

#define DIV (   n,
 
)    ((n)<0 ? NDIV((n),(d)) : (n)/(d))

Definition at line 150 of file date_core.c.

◆ ENGLAND

#define ENGLAND   2361222 /* 1752-09-14 */

Definition at line 167 of file date_core.c.

◆ EX_HOUR

#define EX_HOUR (   x)    (((x) >> HOUR_SHIFT) & PK_MASK(HOUR_WIDTH))

Definition at line 209 of file date_core.c.

◆ EX_MDAY

#define EX_MDAY (   x)    (((x) >> MDAY_SHIFT) & PK_MASK(MDAY_WIDTH))

Definition at line 210 of file date_core.c.

◆ EX_MIN

#define EX_MIN (   x)    (((x) >> MIN_SHIFT) & PK_MASK(MIN_WIDTH))

Definition at line 208 of file date_core.c.

◆ EX_MON

#define EX_MON (   x)    (((x) >> MON_SHIFT) & PK_MASK(MON_WIDTH))

Definition at line 211 of file date_core.c.

◆ EX_SEC

#define EX_SEC (   x)    (((x) >> SEC_SHIFT) & PK_MASK(SEC_WIDTH))

Definition at line 207 of file date_core.c.

◆ f_abs

#define f_abs (   x)    rb_funcall(x, rb_intern("abs"), 0)

Definition at line 30 of file date_core.c.

Referenced by rb_flt_rationalize_with_prec().

◆ f_add

#define f_add (   x,
 
)    rb_funcall(x, '+', 1, y)

Definition at line 32 of file date_core.c.

◆ f_add3

#define f_add3 (   x,
  y,
 
)    f_add(f_add(x, y), z)

Definition at line 51 of file date_core.c.

◆ f_ajd

#define f_ajd (   x)    rb_funcall(x, rb_intern("ajd"), 0)

Definition at line 137 of file date_core.c.

◆ f_boolcast

#define f_boolcast (   x)    ((x) ? Qtrue : Qfalse)

Definition at line 28 of file date_core.c.

◆ f_ceil

#define f_ceil (   x)    rb_funcall(x, rb_intern("ceil"), 0)

Definition at line 42 of file date_core.c.

◆ f_div

#define f_div (   x,
 
)    rb_funcall(x, '/', 1, y)

Definition at line 35 of file date_core.c.

◆ f_expt

#define f_expt (   x,
 
)    rb_funcall(x, rb_intern("**"), 1, y)

Definition at line 40 of file date_core.c.

◆ f_floor

#define f_floor (   x)    rb_funcall(x, rb_intern("floor"), 0)

Definition at line 41 of file date_core.c.

◆ f_hour

#define f_hour (   x)    rb_funcall(x, rb_intern("hour"), 0)

Definition at line 143 of file date_core.c.

◆ f_idiv

#define f_idiv (   x,
 
)    rb_funcall(x, rb_intern("div"), 1, y)

Definition at line 37 of file date_core.c.

◆ f_inspect

#define f_inspect (   x)    rb_funcall(x, rb_intern("inspect"), 0)

Definition at line 49 of file date_core.c.

◆ f_jd

#define f_jd (   x)    rb_funcall(x, rb_intern("jd"), 0)

Definition at line 138 of file date_core.c.

◆ f_local3

#define f_local3 (   x,
  y,
  m,
 
)    rb_funcall(x, rb_intern("local"), 3, y, m, d)

Definition at line 8440 of file date_core.c.

◆ f_mday

#define f_mday (   x)    rb_funcall(x, rb_intern("mday"), 0)

Definition at line 141 of file date_core.c.

◆ f_min

#define f_min (   x)    rb_funcall(x, rb_intern("min"), 0)

Definition at line 144 of file date_core.c.

◆ f_mod

#define f_mod (   x,
 
)    rb_funcall(x, '%', 1, y)

Definition at line 38 of file date_core.c.

◆ f_mon

#define f_mon (   x)    rb_funcall(x, rb_intern("mon"), 0)

Definition at line 140 of file date_core.c.

◆ f_mul

#define f_mul (   x,
 
)    rb_funcall(x, '*', 1, y)

Definition at line 34 of file date_core.c.

◆ f_negate

#define f_negate (   x)    rb_funcall(x, rb_intern("-@"), 0)

Definition at line 31 of file date_core.c.

◆ f_nonzero_p

#define f_nonzero_p (   x)    (!f_zero_p(x))

Definition at line 125 of file date_core.c.

◆ f_positive_p

#define f_positive_p (   x)    (!f_negative_p(x))

Definition at line 135 of file date_core.c.

◆ f_public

#define f_public (   m,
 
)
Value:
rb_funcall(m, rb_intern("public"), 1,\
#define rb_intern(str)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
Definition: vm_eval.c:774
#define ID2SYM(x)
Definition: ruby.h:383

◆ f_quo

#define f_quo (   x,
 
)    rb_funcall(x, rb_intern("quo"), 1, y)

Definition at line 36 of file date_core.c.

◆ f_remainder

#define f_remainder (   x,
 
)    rb_funcall(x, rb_intern("remainder"), 1, y)

Definition at line 39 of file date_core.c.

◆ f_round

#define f_round (   x)    rb_funcall(x, rb_intern("round"), 0)

Definition at line 44 of file date_core.c.

◆ f_sec

#define f_sec (   x)    rb_funcall(x, rb_intern("sec"), 0)

Definition at line 145 of file date_core.c.

◆ f_sub

#define f_sub (   x,
 
)    rb_funcall(x, '-', 1, y)

Definition at line 33 of file date_core.c.

◆ f_sub3

#define f_sub3 (   x,
  y,
 
)    f_sub(f_sub(x, y), z)

Definition at line 52 of file date_core.c.

◆ f_subsec

#define f_subsec (   x)    rb_funcall(x, rb_intern("subsec"), 0)

Definition at line 8438 of file date_core.c.

◆ f_to_i

#define f_to_i (   x)    rb_funcall(x, rb_intern("to_i"), 0)

Definition at line 46 of file date_core.c.

◆ f_to_r

#define f_to_r (   x)    rb_funcall(x, rb_intern("to_r"), 0)

Definition at line 47 of file date_core.c.

◆ f_to_s

#define f_to_s (   x)    rb_funcall(x, rb_intern("to_s"), 0)

Definition at line 48 of file date_core.c.

◆ f_truncate

#define f_truncate (   x)    rb_funcall(x, rb_intern("truncate"), 0)

Definition at line 43 of file date_core.c.

◆ f_utc_offset

#define f_utc_offset (   x)    rb_funcall(x, rb_intern("utc_offset"), 0)

Definition at line 8439 of file date_core.c.

◆ f_wday

#define f_wday (   x)    rb_funcall(x, rb_intern("wday"), 0)

Definition at line 142 of file date_core.c.

◆ f_year

#define f_year (   x)    rb_funcall(x, rb_intern("year"), 0)

Definition at line 139 of file date_core.c.

◆ GC_PERIOD0

#define GC_PERIOD0   146097 /* 365.2425 * 400 */

Definition at line 181 of file date_core.c.

◆ get_d1

#define get_d1 (   x)
Value:
union DateData *dat;\
TypedData_Get_Struct(x, union DateData, &d_lite_type, dat);

Definition at line 288 of file date_core.c.

◆ get_d1a

#define get_d1a (   x)
Value:
union DateData *adat;\
TypedData_Get_Struct(x, union DateData, &d_lite_type, adat);

Definition at line 292 of file date_core.c.

◆ get_d1b

#define get_d1b (   x)
Value:
union DateData *bdat;\
TypedData_Get_Struct(x, union DateData, &d_lite_type, bdat);

Definition at line 296 of file date_core.c.

◆ get_d2

#define get_d2 (   x,
 
)
Value:
union DateData *adat, *bdat;\
TypedData_Get_Struct(x, union DateData, &d_lite_type, adat);\
TypedData_Get_Struct(y, union DateData, &d_lite_type, bdat);

Definition at line 300 of file date_core.c.

◆ GREGORIAN

#define GREGORIAN   negative_inf

Definition at line 169 of file date_core.c.

◆ HALF_DAYS_IN_SECONDS

#define HALF_DAYS_IN_SECONDS   (DAY_IN_SECONDS / 2)

Definition at line 1558 of file date_core.c.

◆ HAVE_CIVIL

#define HAVE_CIVIL   (1 << 2)

Definition at line 155 of file date_core.c.

◆ have_civil_p

#define have_civil_p (   x)    ((x)->flags & HAVE_CIVIL)

Definition at line 161 of file date_core.c.

◆ HAVE_DF

#define HAVE_DF   (1 << 1)

Definition at line 154 of file date_core.c.

◆ have_df_p

#define have_df_p (   x)    ((x)->flags & HAVE_DF)

Definition at line 160 of file date_core.c.

◆ HAVE_JD

#define HAVE_JD   (1 << 0)

Definition at line 153 of file date_core.c.

◆ have_jd_p

#define have_jd_p (   x)    ((x)->flags & HAVE_JD)

Definition at line 159 of file date_core.c.

◆ HAVE_TIME

#define HAVE_TIME   (1 << 3)

Definition at line 156 of file date_core.c.

◆ have_time_p

#define have_time_p (   x)    ((x)->flags & HAVE_TIME)

Definition at line 162 of file date_core.c.

◆ HOUR_IN_SECONDS

#define HOUR_IN_SECONDS   3600

Definition at line 175 of file date_core.c.

◆ HOUR_SHIFT

#define HOUR_SHIFT   (MIN_WIDTH + SEC_WIDTH)

Definition at line 201 of file date_core.c.

◆ HOUR_WIDTH

#define HOUR_WIDTH   5

Definition at line 195 of file date_core.c.

◆ ITALY

#define ITALY   2299161 /* 1582-10-15 */

Definition at line 166 of file date_core.c.

◆ JC_PERIOD0

#define JC_PERIOD0   1461 /* 365.25 * 4 */

Definition at line 180 of file date_core.c.

◆ jd_trunc

#define jd_trunc   d_trunc

Definition at line 3155 of file date_core.c.

◆ JULIAN

#define JULIAN   positive_inf

Definition at line 168 of file date_core.c.

◆ k_trunc

#define k_trunc   d_trunc

Definition at line 3156 of file date_core.c.

◆ MDAY_SHIFT

#define MDAY_SHIFT   (HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)

Definition at line 202 of file date_core.c.

◆ MDAY_WIDTH

#define MDAY_WIDTH   5

Definition at line 196 of file date_core.c.

◆ MILLISECOND_IN_NANOSECONDS

#define MILLISECOND_IN_NANOSECONDS   1000000

Definition at line 6615 of file date_core.c.

◆ MIN_SHIFT

#define MIN_SHIFT   SEC_WIDTH

Definition at line 200 of file date_core.c.

◆ MIN_WIDTH

#define MIN_WIDTH   6

Definition at line 194 of file date_core.c.

◆ MINUTE_IN_SECONDS

#define MINUTE_IN_SECONDS   60

Definition at line 174 of file date_core.c.

◆ MOD

#define MOD (   n,
 
)    ((n)<0 ? NMOD((n),(d)) : (n)%(d))

Definition at line 151 of file date_core.c.

◆ MON_SHIFT

#define MON_SHIFT   (MDAY_WIDTH + HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)

Definition at line 203 of file date_core.c.

◆ MON_WIDTH

#define MON_WIDTH   4

Definition at line 197 of file date_core.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file date_core.c.

◆ NDIV

#define NDIV (   x,
 
)    (-(-((x)+1)/(y))-1)

Definition at line 148 of file date_core.c.

◆ NMOD

#define NMOD (   x,
 
)    ((y)-(-((x)+1)%(y))-1)

Definition at line 149 of file date_core.c.

◆ num2int_with_frac

#define num2int_with_frac (   s,
 
)
Value:
{\
s = NUM2INT(s##_trunc(v##s, &fr));\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
}
#define NUM2INT(x)
Definition: ruby.h:684
#define f_nonzero_p(x)
Definition: date_core.c:125
VALUE rb_eArgError
Definition: error.c:802
int argc
Definition: ruby.c:187
struct SimpleDateData s
Definition: date_core.c:284

Definition at line 3219 of file date_core.c.

◆ num2num_with_frac

#define num2num_with_frac (   s,
 
)
Value:
{\
s = s##_trunc(v##s, &fr);\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(rb_eArgError, "invalid fraction");\
fr2 = fr;\
}\
}
#define f_nonzero_p(x)
Definition: date_core.c:125
VALUE rb_eArgError
Definition: error.c:802
int argc
Definition: ruby.c:187
struct SimpleDateData s
Definition: date_core.c:284

Definition at line 3209 of file date_core.c.

◆ PACK2

#define PACK2 (   m,
 
)    (((m) << MON_SHIFT) | ((d) << MDAY_SHIFT))

Definition at line 217 of file date_core.c.

◆ PACK5

#define PACK5 (   m,
  d,
  h,
  min,
 
)
Value:
(((m) << MON_SHIFT) | ((d) << MDAY_SHIFT) |\
((h) << HOUR_SHIFT) | ((min) << MIN_SHIFT) | ((s) << SEC_SHIFT))
#define MDAY_SHIFT
Definition: date_core.c:202
#define MON_SHIFT
Definition: date_core.c:203
#define SEC_SHIFT
Definition: date_core.c:199
#define HOUR_SHIFT
Definition: date_core.c:201
#define MIN_SHIFT
Definition: date_core.c:200
struct SimpleDateData s
Definition: date_core.c:284

Definition at line 213 of file date_core.c.

◆ PK_MASK

#define PK_MASK (   x)    ((1 << (x)) - 1)

Definition at line 205 of file date_core.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

◆ ref_hash

#define ref_hash (   k)    rb_hash_aref(hash, ID2SYM(rb_intern(k)))

Definition at line 3683 of file date_core.c.

◆ ref_hash0

#define ref_hash0 (   k)    rb_hash_aref(hash, k)

Definition at line 3679 of file date_core.c.

◆ REFORM_BEGIN_JD

#define REFORM_BEGIN_JD   2298874 /* ns 1582-01-01 */

Definition at line 189 of file date_core.c.

◆ REFORM_BEGIN_YEAR

#define REFORM_BEGIN_YEAR   1582

Definition at line 187 of file date_core.c.

◆ REFORM_END_JD

#define REFORM_END_JD   2426355 /* os 1930-12-31 */

Definition at line 190 of file date_core.c.

◆ REFORM_END_YEAR

#define REFORM_END_YEAR   1930

Definition at line 188 of file date_core.c.

◆ SEC_SHIFT

#define SEC_SHIFT   0

Definition at line 199 of file date_core.c.

◆ SEC_WIDTH

#define SEC_WIDTH   6

Definition at line 193 of file date_core.c.

◆ SECOND_IN_MILLISECONDS

#define SECOND_IN_MILLISECONDS   1000

Definition at line 177 of file date_core.c.

◆ SECOND_IN_NANOSECONDS

#define SECOND_IN_NANOSECONDS   1000000000

Definition at line 178 of file date_core.c.

◆ set_hash

#define set_hash (   k,
 
)    rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)

Definition at line 3682 of file date_core.c.

◆ set_hash0

#define set_hash0 (   k,
 
)    rb_hash_aset(hash, k, v)

Definition at line 3678 of file date_core.c.

◆ set_to_complex

#define set_to_complex (   obj,
  x,
  _nth,
  _jd,
  _df,
  _sf,
  _of,
  _sg,
  _year,
  _mon,
  _mday,
  _hour,
  _min,
  _sec,
  _flags 
)
Value:
{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
(x)->jd = _jd;\
(x)->df = _df;\
RB_OBJ_WRITE((obj), &(x)->sf, canon(_sf));\
(x)->of = _of;\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->pc = PACK5(_mon, _mday, _hour, _min, _sec);\
(x)->flags = _flags;\
}
#define PACK5(m, d, h, min, s)
Definition: date_core.c:213
unsigned flags
Definition: date_core.c:283
#define date_sg_t
Definition: date_core.c:228

Definition at line 358 of file date_core.c.

◆ set_to_simple

#define set_to_simple (   obj,
  x,
  _nth,
  _jd,
  _sg,
  _year,
  _mon,
  _mday,
  _flags 
)
Value:
{\
RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
(x)->jd = _jd;\
(x)->sg = (date_sg_t)(_sg);\
(x)->year = _year;\
(x)->pc = PACK2(_mon, _mday);\
(x)->flags = _flags;\
}
unsigned flags
Definition: date_core.c:283
#define PACK2(m, d)
Definition: date_core.c:217
#define date_sg_t
Definition: date_core.c:228

Definition at line 328 of file date_core.c.

◆ simple_dat_p

#define simple_dat_p (   x)    (!complex_dat_p(x))

Definition at line 164 of file date_core.c.

◆ SMALLBUF

#define SMALLBUF   100

Definition at line 6563 of file date_core.c.

◆ sym

#define sym (   x)    ID2SYM(rb_intern(x))

◆ UNIX_EPOCH_IN_CJD

#define UNIX_EPOCH_IN_CJD   INT2FIX(2440588) /* 1970-01-01 */

Definition at line 172 of file date_core.c.

◆ USE_PACK

#define USE_PACK

Definition at line 21 of file date_core.c.

◆ val2off

#define val2off (   vof,
  iof 
)
Value:
{\
if (!offset_to_sec(vof, &iof)) {\
iof = 0;\
rb_warning("invalid offset is ignored");\
}\
}

Definition at line 4693 of file date_core.c.

◆ val2sg

#define val2sg (   vsg,
  dsg 
)
Value:
{\
dsg = NUM2DBL(vsg);\
if (!c_valid_start_p(dsg)) {\
dsg = DEFAULT_SG;\
rb_warning("invalid start is ignored");\
}\
}
#define NUM2DBL(x)
Definition: ruby.h:743
#define DEFAULT_SG
Definition: date_core.c:170

Definition at line 3243 of file date_core.c.

◆ valid_sg

#define valid_sg (   sg)
Value:
{\
if (!c_valid_start_p(sg)) {\
sg = 0;\
rb_warning("invalid start is ignored");\
}\
}

Definition at line 2422 of file date_core.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DECIMAL_SIZE_OF_LONG 
JISX0301_DATE_SIZE 

Definition at line 6997 of file date_core.c.

Function Documentation

◆ date__httpdate()

VALUE date__httpdate ( VALUE  )

Definition at line 2903 of file date_parse.c.

◆ date__iso8601()

VALUE date__iso8601 ( VALUE  )

Definition at line 2470 of file date_parse.c.

◆ date__jisx0301()

VALUE date__jisx0301 ( VALUE  )

Definition at line 2977 of file date_parse.c.

◆ date__parse()

VALUE date__parse ( VALUE  str,
VALUE  comp 
)

Definition at line 2049 of file date_parse.c.

◆ date__rfc2822()

VALUE date__rfc2822 ( VALUE  )

Definition at line 2757 of file date_parse.c.

◆ date__rfc3339()

VALUE date__rfc3339 ( VALUE  )

Definition at line 2538 of file date_parse.c.

◆ date__strptime()

VALUE date__strptime ( const char *  str,
size_t  slen,
const char *  fmt,
size_t  flen,
VALUE  hash 
)

Definition at line 653 of file date_strptime.c.

◆ date__xmlschema()

VALUE date__xmlschema ( VALUE  )

Definition at line 2684 of file date_parse.c.

◆ date_strftime()

size_t date_strftime ( char *  s,
size_t  maxsize,
const char *  format,
const struct tmx tmx 
)

Definition at line 628 of file date_strftime.c.

◆ date_zone_to_diff()

VALUE date_zone_to_diff ( VALUE  )

Definition at line 353 of file date_parse.c.

◆ Init_date_core()

void Init_date_core ( void  )

Definition at line 9014 of file date_core.c.

References assert.