Ruby: ext/date/date_core.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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_frozen_ary(...) rb_obj_freeze(rb_ary_new3(__VA_ARGS__))
#define | RETURN_FALSE_UNLESS_NUMERIC(obj) if(!RTEST(rb_obj_is_kind_of((obj), rb_cNumeric))) return Qfalse
#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 | sym(x) ID2SYM(rb_intern(x""))
#define | set_hash(k, v) set_hash0(sym(k), v)
#define | ref_hash(k) ref_hash0(sym(k))
#define | del_hash(k) del_hash0(sym(k))
#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)

## 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:
do {\
if (f_nonzero_p(fr2))\
ret = d_lite_plus(ret, fr2);\
} while (0)
f_nonzero_p
#define f_nonzero_p(x)
Definition: date_core.c:140

Definition at line 3265 of file date_core.c.

## ◆ canon24oc

#define canon24oc | ( |  | ) |

Value:
do {\
if (rh == 24) {\
rh = 0;\
fr2 = f_add(fr2, INT2FIX(1));\
}\
} while (0)
f_add
#define f_add(x, y)
Definition: date_core.c:34
INT2FIX
#define INT2FIX
Definition: long.h:48

Definition at line 3257 of file date_core.c.

## ◆ canonicalize_jd

#define canonicalize_jd | ( |  | _nth,
|  |  | _jd
| ) |  |

Value:
do {\
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;\
}\
} while (0)
f_sub
#define f_sub(x, y)
Definition: date_core.c:35
CM_PERIOD
#define CM_PERIOD
Definition: date_core.c:198

Definition at line 1123 of file date_core.c.

## ◆ CM_PERIOD

#define CM_PERIOD (0xfffffff / CM_PERIOD0 * CM_PERIOD0)

Definition at line 198 of file date_core.c.

## ◆ CM_PERIOD0

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

Definition at line 197 of file date_core.c.

## ◆ CM_PERIOD_GCY

#define CM_PERIOD_GCY (CM_PERIOD / GC_PERIOD0 * 400)

Definition at line 200 of file date_core.c.

## ◆ CM_PERIOD_JCY

#define CM_PERIOD_JCY (CM_PERIOD / JC_PERIOD0 * 4)

Definition at line 199 of file date_core.c.

## ◆ COMPLEX_DAT

#define COMPLEX_DAT (1 << 7)

Definition at line 172 of file date_core.c.

## ◆ complex_dat_p

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

Definition at line 178 of file date_core.c.

## ◆ copy_complex_to_simple

#define copy_complex_to_simple | ( |  | obj,
|  |  | x,
|  |  | y
| ) |  |

Value:
do {\
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;\
} while (0)
EX_MON
#define EX_MON(x)
Definition: date_core.c:226
EX_MDAY
#define EX_MDAY(x)
Definition: date_core.c:225
date_sg_t
#define date_sg_t
Definition: date_core.c:243
PACK2
#define PACK2(m, d)
Definition: date_core.c:232

Definition at line 429 of file date_core.c.

## ◆ copy_simple_to_complex

#define copy_simple_to_complex | ( |  | obj,
|  |  | x,
|  |  | y
| ) |  |

Value:
do {\
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;\
} while (0)
PACK5
#define PACK5(m, d, h, min, s)
Definition: date_core.c:228

Definition at line 403 of file date_core.c.

## ◆ date_sg_t

#define date_sg_t double

Definition at line 243 of file date_core.c.

## ◆ DAY_IN_SECONDS

#define DAY_IN_SECONDS 86400

Definition at line 191 of file date_core.c.

## ◆ decode_offset

#define decode_offset | ( |  | of,
|  |  | s,
|  |  | h,
|  |  | m
| ) |  |

Value:
do {\
int a;\
s = (of < 0) ? '-' : '+';\
a = (of < 0) ? -of : of;\
h = a / HOUR_IN_SECONDS;\
m = a % HOUR_IN_SECONDS / MINUTE_IN_SECONDS;\
} while (0)
MINUTE_IN_SECONDS
#define MINUTE_IN_SECONDS
Definition: date_core.c:189
HOUR_IN_SECONDS
#define HOUR_IN_SECONDS
Definition: date_core.c:190

Definition at line 1942 of file date_core.c.

## ◆ DEFAULT_SG

#define DEFAULT_SG ITALY

Definition at line 185 of file date_core.c.

## ◆ del_hash

#define del_hash | ( |  | k | ) | del_hash0(sym(k))

Definition at line 3727 of file date_core.c.

## ◆ del_hash0

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

Definition at line 3721 of file date_core.c.

## ◆ DIV

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

Definition at line 165 of file date_core.c.

## ◆ ENGLAND

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

Definition at line 182 of file date_core.c.

## ◆ EX_HOUR

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

Definition at line 224 of file date_core.c.

## ◆ EX_MDAY

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

Definition at line 225 of file date_core.c.

## ◆ EX_MIN

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

Definition at line 223 of file date_core.c.

## ◆ EX_MON

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

Definition at line 226 of file date_core.c.

## ◆ EX_SEC

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

Definition at line 222 of file date_core.c.

## ◆ f_abs

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

Definition at line 32 of file date_core.c.

## ◆ f_add

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

Definition at line 34 of file date_core.c.

## ◆ f_add3

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

Definition at line 53 of file date_core.c.

## ◆ f_ajd

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

Definition at line 152 of file date_core.c.

## ◆ f_boolcast

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

Definition at line 30 of file date_core.c.

## ◆ f_ceil

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

Definition at line 44 of file date_core.c.

## ◆ f_div

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

Definition at line 37 of file date_core.c.

## ◆ f_expt

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

Definition at line 42 of file date_core.c.

## ◆ f_floor

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

Definition at line 43 of file date_core.c.

## ◆ f_frozen_ary

#define f_frozen_ary | ( |  | ... | ) | rb_obj_freeze(rb_ary_new3(__VA_ARGS__))

Definition at line 56 of file date_core.c.

## ◆ f_hour

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

Definition at line 158 of file date_core.c.

## ◆ f_idiv

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

Definition at line 39 of file date_core.c.

## ◆ f_inspect

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

Definition at line 51 of file date_core.c.

## ◆ f_jd

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

Definition at line 153 of file date_core.c.

## ◆ f_local3

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

Definition at line 8747 of file date_core.c.

## ◆ f_mday

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

Definition at line 156 of file date_core.c.

## ◆ f_min

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

Definition at line 159 of file date_core.c.

## ◆ f_mod

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

Definition at line 40 of file date_core.c.

## ◆ f_mon

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

Definition at line 155 of file date_core.c.

## ◆ f_mul

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

Definition at line 36 of file date_core.c.

## ◆ f_negate

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

Definition at line 33 of file date_core.c.

## ◆ f_nonzero_p

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

Definition at line 140 of file date_core.c.

## ◆ f_positive_p

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

Definition at line 150 of file date_core.c.

## ◆ f_quo

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

Definition at line 38 of file date_core.c.

## ◆ f_remainder

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

Definition at line 41 of file date_core.c.

## ◆ f_round

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

Definition at line 46 of file date_core.c.

## ◆ f_sec

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

Definition at line 160 of file date_core.c.

## ◆ f_sub

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

Definition at line 35 of file date_core.c.

## ◆ f_sub3

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

Definition at line 54 of file date_core.c.

## ◆ f_subsec

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

Definition at line 8745 of file date_core.c.

## ◆ f_to_i

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

Definition at line 48 of file date_core.c.

## ◆ f_to_r

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

Definition at line 49 of file date_core.c.

## ◆ f_to_s

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

Definition at line 50 of file date_core.c.

## ◆ f_truncate

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

Definition at line 45 of file date_core.c.

## ◆ f_utc_offset

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

Definition at line 8746 of file date_core.c.

## ◆ f_wday

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

Definition at line 157 of file date_core.c.

## ◆ f_year

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

Definition at line 154 of file date_core.c.

## ◆ GC_PERIOD0

#define GC_PERIOD0 146097 /* 365.2425 * 400 */

Definition at line 196 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);
DateData
Definition: date_core.c:294

Definition at line 300 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 304 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 308 of file date_core.c.

## ◆ get_d2

#define get_d2 | ( |  | x,
|  |  | y
| ) |  |

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 312 of file date_core.c.

## ◆ GREGORIAN

#define GREGORIAN negative_inf

Definition at line 184 of file date_core.c.

## ◆ HALF_DAYS_IN_SECONDS

#define HALF_DAYS_IN_SECONDS (DAY_IN_SECONDS / 2)

Definition at line 1570 of file date_core.c.

## ◆ HAVE_CIVIL

#define HAVE_CIVIL (1 << 2)

Definition at line 170 of file date_core.c.

## ◆ have_civil_p

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

Definition at line 176 of file date_core.c.

## ◆ HAVE_DF

#define HAVE_DF (1 << 1)

Definition at line 169 of file date_core.c.

## ◆ have_df_p

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

Definition at line 175 of file date_core.c.

## ◆ HAVE_JD

#define HAVE_JD (1 << 0)

Definition at line 168 of file date_core.c.

## ◆ have_jd_p

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

Definition at line 174 of file date_core.c.

## ◆ HAVE_TIME

#define HAVE_TIME (1 << 3)

Definition at line 171 of file date_core.c.

## ◆ have_time_p

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

Definition at line 177 of file date_core.c.

## ◆ HOUR_IN_SECONDS

#define HOUR_IN_SECONDS 3600

Definition at line 190 of file date_core.c.

## ◆ HOUR_SHIFT

#define HOUR_SHIFT (MIN_WIDTH + SEC_WIDTH)

Definition at line 216 of file date_core.c.

## ◆ HOUR_WIDTH

#define HOUR_WIDTH 5

Definition at line 210 of file date_core.c.

## ◆ ITALY

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

Definition at line 181 of file date_core.c.

## ◆ JC_PERIOD0

#define JC_PERIOD0 1461 /* 365.25 * 4 */

Definition at line 195 of file date_core.c.

## ◆ jd_trunc

#define jd_trunc d_trunc

Definition at line 3183 of file date_core.c.

## ◆ JULIAN

#define JULIAN positive_inf

Definition at line 183 of file date_core.c.

## ◆ k_trunc

#define k_trunc d_trunc

Definition at line 3184 of file date_core.c.

## ◆ MDAY_SHIFT

#define MDAY_SHIFT (HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)

Definition at line 217 of file date_core.c.

## ◆ MDAY_WIDTH

#define MDAY_WIDTH 5

Definition at line 211 of file date_core.c.

## ◆ MILLISECOND_IN_NANOSECONDS

#define MILLISECOND_IN_NANOSECONDS 1000000

Definition at line 6820 of file date_core.c.

## ◆ MIN_SHIFT

#define MIN_SHIFT SEC_WIDTH

Definition at line 215 of file date_core.c.

## ◆ MIN_WIDTH

#define MIN_WIDTH 6

Definition at line 209 of file date_core.c.

## ◆ MINUTE_IN_SECONDS

#define MINUTE_IN_SECONDS 60

Definition at line 189 of file date_core.c.

## ◆ MOD

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

Definition at line 166 of file date_core.c.

## ◆ MON_SHIFT

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

Definition at line 218 of file date_core.c.

## ◆ MON_WIDTH

#define MON_WIDTH 4

Definition at line 212 of file date_core.c.

## ◆ NDEBUG

#define NDEBUG

Definition at line 15 of file date_core.c.

## ◆ NDIV

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

Definition at line 163 of file date_core.c.

## ◆ NMOD

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

Definition at line 164 of file date_core.c.

## ◆ num2int_with_frac

#define num2int_with_frac | ( |  | s,
|  |  | n
| ) |  |

Value:
do {\
s = NUM2INT(s##_trunc(v##s, &fr));\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(eDateError, "invalid fraction");\
fr2 = fr;\
}\
} while (0)
NUM2INT
#define NUM2INT
Definition: int.h:44
argc
int argc
Definition: ruby.c:240

Definition at line 3247 of file date_core.c.

## ◆ num2num_with_frac

#define num2num_with_frac | ( |  | s,
|  |  | n
| ) |  |

Value:
do {\
s = s##_trunc(v##s, &fr);\
if (f_nonzero_p(fr)) {\
if (argc > n)\
rb_raise(eDateError, "invalid fraction");\
fr2 = fr;\
}\
} while (0)

Definition at line 3237 of file date_core.c.

## ◆ PACK2

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

Definition at line 232 of file date_core.c.

## ◆ PACK5

#define PACK5 | ( |  | m,
|  |  | d,
|  |  | h,
|  |  | min,
|  |  | s
| ) |  |

Value:
(((m) << MON_SHIFT) | ((d) << MDAY_SHIFT) |\
((h) << HOUR_SHIFT) | ((min) << MIN_SHIFT) | ((s) << SEC_SHIFT))
MON_SHIFT
#define MON_SHIFT
Definition: date_core.c:218
HOUR_SHIFT
#define HOUR_SHIFT
Definition: date_core.c:216
SEC_SHIFT
#define SEC_SHIFT
Definition: date_core.c:214
MIN_SHIFT
#define MIN_SHIFT
Definition: date_core.c:215
MDAY_SHIFT
#define MDAY_SHIFT
Definition: date_core.c:217

Definition at line 228 of file date_core.c.

## ◆ PK_MASK

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

Definition at line 220 of file date_core.c.

## ◆ ref_hash

#define ref_hash | ( |  | k | ) | ref_hash0(sym(k))

Definition at line 3726 of file date_core.c.

## ◆ ref_hash0

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

Definition at line 3720 of file date_core.c.

## ◆ REFORM_BEGIN_JD

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

Definition at line 204 of file date_core.c.

## ◆ REFORM_BEGIN_YEAR

#define REFORM_BEGIN_YEAR 1582

Definition at line 202 of file date_core.c.

## ◆ REFORM_END_JD

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

Definition at line 205 of file date_core.c.

## ◆ REFORM_END_YEAR

#define REFORM_END_YEAR 1930

Definition at line 203 of file date_core.c.

## ◆ RETURN_FALSE_UNLESS_NUMERIC

#define RETURN_FALSE_UNLESS_NUMERIC | ( |  | obj | ) | if(!RTEST(rb_obj_is_kind_of((obj), rb_cNumeric))) return Qfalse

Definition at line 61 of file date_core.c.

## ◆ SEC_SHIFT

#define SEC_SHIFT 0

Definition at line 214 of file date_core.c.

## ◆ SEC_WIDTH

#define SEC_WIDTH 6

Definition at line 208 of file date_core.c.

## ◆ SECOND_IN_MILLISECONDS

#define SECOND_IN_MILLISECONDS 1000

Definition at line 192 of file date_core.c.

## ◆ SECOND_IN_NANOSECONDS

#define SECOND_IN_NANOSECONDS 1000000000

Definition at line 193 of file date_core.c.

## ◆ set_hash

#define set_hash | ( |  | k,
|  |  | v
| ) |  | set_hash0(sym(k), v)

Definition at line 3725 of file date_core.c.

## ◆ set_hash0

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

Definition at line 3719 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:
do {\
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) | COMPLEX_DAT;\
} while (0)
COMPLEX_DAT
#define COMPLEX_DAT
Definition: date_core.c:172

Definition at line 370 of file date_core.c.

## ◆ set_to_simple

#define set_to_simple | ( |  | obj,
|  |  | x,
|  |  | _nth,
|  |  | _jd,
|  |  | _sg,
|  |  | _year,
|  |  | _mon,
|  |  | _mday,
|  |  | _flags
| ) |  |

Value:
do {\
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) & ~COMPLEX_DAT;\
} while (0)

Definition at line 340 of file date_core.c.

## ◆ simple_dat_p

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

Definition at line 179 of file date_core.c.

## ◆ SMALLBUF

#define SMALLBUF 100

Definition at line 6768 of file date_core.c.

## ◆ sym

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

Definition at line 3723 of file date_core.c.

## ◆ UNIX_EPOCH_IN_CJD

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

Definition at line 187 of file date_core.c.

## ◆ USE_PACK

#define USE_PACK

Definition at line 22 of file date_core.c.

## ◆ val2off

#define val2off | ( |  | vof,
|  |  | iof
| ) |  |

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

Definition at line 4878 of file date_core.c.

## ◆ val2sg

#define val2sg | ( |  | vsg,
|  |  | dsg
| ) |  |

Value:
do {\
dsg = NUM2DBL(vsg);\
if (!c_valid_start_p(dsg)) {\
dsg = DEFAULT_SG;\
rb_warning("invalid start is ignored");\
}\
} while (0)
DEFAULT_SG
#define DEFAULT_SG
Definition: date_core.c:185
NUM2DBL
#define NUM2DBL
Definition: double.h:27

Definition at line 3271 of file date_core.c.

## ◆ valid_sg

#define valid_sg | ( |  | sg | ) |

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

Definition at line 2432 of file date_core.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
DECIMAL_SIZE_OF_LONG |
JISX0301_DATE_SIZE |

Definition at line 7202 of file date_core.c.

## Function Documentation

## ◆ date__httpdate()

VALUE date__httpdate | ( | VALUE | str | ) |

Definition at line 2941 of file date_parse.c.

References rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

## ◆ date__iso8601()

VALUE date__iso8601 | ( | VALUE | str | ) |

Definition at line 2508 of file date_parse.c.

References rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

Referenced by date__jisx0301().

## ◆ date__jisx0301()

VALUE date__jisx0301 | ( | VALUE | str | ) |

Definition at line 3015 of file date_parse.c.

References date__iso8601(), rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

## ◆ date__parse()

VALUE date__parse | ( | VALUE | str,
|  | VALUE | comp
| ) |  |

Definition at line 2090 of file date_parse.c.

References asp_string, date_zone_to_diff(), del_hash, f_add, f_ge_p, f_gsub_bang, f_le_p, f_negate, HAVE_ALPHA, HAVE_DASH, HAVE_DIGIT, HAVE_DOT, HAVE_ELEM_P, HAVE_SLASH, INT2FIX, NIL_P, Qnil, rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), rb_str_dup(), ref_hash, REGCOMP_0, RTEST, set_hash, and str.

## ◆ date__rfc2822()

VALUE date__rfc2822 | ( | VALUE | str | ) |

Definition at line 2795 of file date_parse.c.

References rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

## ◆ date__rfc3339()

VALUE date__rfc3339 | ( | VALUE | str | ) |

Definition at line 2576 of file date_parse.c.

References rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

## ◆ date__strptime()

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

Definition at line 655 of file date_strptime.c.

References del_hash, f_add, f_mod, f_mul, fail_p, INT2FIX, NIL_P, Qnil, rb_usascii_str_new, ref_hash, set_hash, and str.

## ◆ date__xmlschema()

VALUE date__xmlschema | ( | VALUE | str | ) |

Definition at line 2722 of file date_parse.c.

References rb_backref_get(), rb_backref_set(), rb_hash_new(), rb_match_busy(), and str.

## ◆ 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 | str | ) |

Definition at line 411 of file date_parse.c.

References ALLOCV_END, ALLOCV_N, f_add, INT2FIX, issign, MAX_WORD_LENGTH, num, zone::offset, Qnil, RB_GC_GUARD, rb_int_positive_pow(), rb_rational_new(), RSTRING_LEN, RSTRING_PTR, ruby_scan_digits(), str, strncasecmp, STRTOUL, and zonetab().

## ◆ Init_date_core()

void Init_date_core | ( | void |  | ) |

Definition at line 9334 of file date_core.c.

References CLASS_OF, DAY_IN_SECONDS, DBL2NUM, ENGLAND, f_mul, GREGORIAN, id_cmp, INFINITY, INT2FIX, ITALY, JULIAN, LL2NUM, LONG2NUM, rb_cObject, rb_cTime, rb_define_alias(), rb_define_alloc_func(), rb_define_class(), rb_define_class_under(), rb_define_const(), rb_define_method, rb_define_private_method, rb_define_singleton_method, rb_eArgError, RB_EXT_RACTOR_SAFE, rb_gc_register_mark_object(), rb_include_module(), rb_mComparable, rb_rational_new2, rb_singleton_class(), rb_undef_method(), and SECOND_IN_NANOSECONDS.