Ruby  3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
Macros | Functions
date_parse.c File Reference

(b76ad15ed0da636161de0243c547ee1e6fc95681)

#include "ruby.h"
#include "ruby/encoding.h"
#include "ruby/re.h"
#include <ctype.h>
#include "zonetab.h"
Include dependency graph for date_parse.c:

Go to the source code of this file.

Macros

#define sizeof_array(o)   (sizeof o / sizeof o[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_idiv(x, y)   rb_funcall(x, rb_intern("div"), 1, y)
 
#define f_mod(x, y)   rb_funcall(x, '%', 1, y)
 
#define f_expt(x, y)   rb_funcall(x, rb_intern("**"), 1, y)
 
#define f_lt_p(x, y)   rb_funcall(x, '<', 1, y)
 
#define f_gt_p(x, y)   rb_funcall(x, '>', 1, y)
 
#define f_le_p(x, y)   rb_funcall(x, rb_intern("<="), 1, y)
 
#define f_ge_p(x, y)   rb_funcall(x, rb_intern(">="), 1, y)
 
#define f_to_s(x)   rb_funcall(x, rb_intern("to_s"), 0)
 
#define f_match(r, s)   rb_funcall(r, rb_intern("match"), 1, s)
 
#define f_aref(o, i)   rb_funcall(o, rb_intern("[]"), 1, i)
 
#define f_aref2(o, i, j)   rb_funcall(o, rb_intern("[]"), 2, i, j)
 
#define f_begin(o, i)   rb_funcall(o, rb_intern("begin"), 1, i)
 
#define f_end(o, i)   rb_funcall(o, rb_intern("end"), 1, i)
 
#define f_aset(o, i, v)   rb_funcall(o, rb_intern("[]="), 2, i, v)
 
#define f_aset2(o, i, j, v)   rb_funcall(o, rb_intern("[]="), 3, i, j, v)
 
#define f_sub_bang(s, r, x)   rb_funcall(s, rb_intern("sub!"), 2, r, x)
 
#define f_gsub_bang(s, r, x)   rb_funcall(s, rb_intern("gsub!"), 2, r, x)
 
#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 cstr2num(s)   rb_cstr_to_inum(s, 10, 0)
 
#define str2num(s)   rb_str_to_inum(s, 10, 0)
 
#define issign(c)   ((c) == '-' || (c) == '+')
 
#define asp_string()   rb_str_new(" ", 1)
 
#define DAYS   "sunday|monday|tuesday|wednesday|thursday|friday|saturday"
 
#define MONTHS   "january|february|march|april|may|june|july|august|september|october|november|december"
 
#define ABBR_DAYS   "sun|mon|tue|wed|thu|fri|sat"
 
#define ABBR_MONTHS   "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec"
 
#define REGCOMP(pat, opt)
 
#define REGCOMP_0(pat)   REGCOMP(pat, 0)
 
#define REGCOMP_I(pat)   REGCOMP(pat, ONIG_OPTION_IGNORECASE)
 
#define MATCH(s, p, c)
 
#define SUBS(s, p, c)
 
#define JISX0301_ERA_INITIALS   "mtshr"
 
#define JISX0301_DEFAULT_ERA   'H' /* obsolete */
 
#define HAVE_ALPHA   (1<<0)
 
#define HAVE_DIGIT   (1<<1)
 
#define HAVE_DASH   (1<<2)
 
#define HAVE_DOT   (1<<3)
 
#define HAVE_SLASH   (1<<4)
 
#define HAVE_ELEM_P(x)   ((check_class(str) & (x)) == (x))
 
#define SNUM   14
 
#define SNUM   17
 
#define SNUM   5
 
#define iso8601_bas_time_cb   iso8601_ext_time_cb
 
#define SNUM   8
 
#define SNUM   8
 
#define SNUM   5
 
#define SNUM   4
 
#define SNUM   8
 
#define SNUM   8
 
#define SNUM   8
 
#define SNUM   7
 
#define SNUM   9
 

Functions

RUBY_EXTERN VALUE rb_int_positive_pow (long x, unsigned long y)
 
RUBY_EXTERN unsigned long ruby_scan_digits (const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
 
VALUE date_zone_to_diff (VALUE str)
 

Macro Definition Documentation

◆ ABBR_DAYS

#define ABBR_DAYS   "sun|mon|tue|wed|thu|fri|sat"

Definition at line 253 of file date_parse.c.

◆ ABBR_MONTHS

#define ABBR_MONTHS   "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec"

Definition at line 254 of file date_parse.c.

◆ asp_string

#define asp_string ( )    rb_str_new(" ", 1)

Definition at line 61 of file date_parse.c.

◆ cstr2num

#define cstr2num (   s)    rb_cstr_to_inum(s, 10, 0)

Definition at line 47 of file date_parse.c.

◆ DAYS

#define DAYS   "sunday|monday|tuesday|wednesday|thursday|friday|saturday"

Definition at line 251 of file date_parse.c.

◆ del_hash

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

Definition at line 45 of file date_parse.c.

◆ f_add

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

Definition at line 18 of file date_parse.c.

◆ f_aref

#define f_aref (   o,
 
)    rb_funcall(o, rb_intern("[]"), 1, i)

Definition at line 34 of file date_parse.c.

◆ f_aref2

#define f_aref2 (   o,
  i,
 
)    rb_funcall(o, rb_intern("[]"), 2, i, j)

Definition at line 35 of file date_parse.c.

◆ f_aset

#define f_aset (   o,
  i,
 
)    rb_funcall(o, rb_intern("[]="), 2, i, v)

Definition at line 38 of file date_parse.c.

◆ f_aset2

#define f_aset2 (   o,
  i,
  j,
 
)    rb_funcall(o, rb_intern("[]="), 3, i, j, v)

Definition at line 39 of file date_parse.c.

◆ f_begin

#define f_begin (   o,
 
)    rb_funcall(o, rb_intern("begin"), 1, i)

Definition at line 36 of file date_parse.c.

◆ f_div

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

Definition at line 21 of file date_parse.c.

◆ f_end

#define f_end (   o,
 
)    rb_funcall(o, rb_intern("end"), 1, i)

Definition at line 37 of file date_parse.c.

◆ f_expt

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

Definition at line 24 of file date_parse.c.

◆ f_ge_p

#define f_ge_p (   x,
  y 
)    rb_funcall(x, rb_intern(">="), 1, y)

Definition at line 29 of file date_parse.c.

◆ f_gsub_bang

#define f_gsub_bang (   s,
  r,
 
)    rb_funcall(s, rb_intern("gsub!"), 2, r, x)

Definition at line 41 of file date_parse.c.

◆ f_gt_p

#define f_gt_p (   x,
  y 
)    rb_funcall(x, '>', 1, y)

Definition at line 27 of file date_parse.c.

◆ f_idiv

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

Definition at line 22 of file date_parse.c.

◆ f_le_p

#define f_le_p (   x,
  y 
)    rb_funcall(x, rb_intern("<="), 1, y)

Definition at line 28 of file date_parse.c.

◆ f_lt_p

#define f_lt_p (   x,
  y 
)    rb_funcall(x, '<', 1, y)

Definition at line 26 of file date_parse.c.

◆ f_match

#define f_match (   r,
 
)    rb_funcall(r, rb_intern("match"), 1, s)

Definition at line 33 of file date_parse.c.

◆ f_mod

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

Definition at line 23 of file date_parse.c.

◆ f_mul

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

Definition at line 20 of file date_parse.c.

◆ f_negate

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

Definition at line 17 of file date_parse.c.

◆ f_sub

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

Definition at line 19 of file date_parse.c.

◆ f_sub_bang

#define f_sub_bang (   s,
  r,
 
)    rb_funcall(s, rb_intern("sub!"), 2, r, x)

Definition at line 40 of file date_parse.c.

◆ f_to_s

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

Definition at line 31 of file date_parse.c.

◆ HAVE_ALPHA

#define HAVE_ALPHA   (1<<0)

◆ HAVE_DASH

#define HAVE_DASH   (1<<2)

◆ HAVE_DIGIT

#define HAVE_DIGIT   (1<<1)

◆ HAVE_DOT

#define HAVE_DOT   (1<<3)

◆ HAVE_ELEM_P

#define HAVE_ELEM_P (   x)    ((check_class(str) & (x)) == (x))

◆ HAVE_SLASH

#define HAVE_SLASH   (1<<4)

◆ iso8601_bas_time_cb

#define iso8601_bas_time_cb   iso8601_ext_time_cb

◆ issign

#define issign (   c)    ((c) == '-' || (c) == '+')

Definition at line 60 of file date_parse.c.

◆ JISX0301_DEFAULT_ERA

#define JISX0301_DEFAULT_ERA   'H' /* obsolete */

◆ JISX0301_ERA_INITIALS

#define JISX0301_ERA_INITIALS   "mtshr"

◆ MATCH

#define MATCH (   s,
  p,
 
)
Value:
do { \
return match(s, p, hash, c); \
} while (0)

Definition at line 293 of file date_parse.c.

◆ MONTHS

#define MONTHS   "january|february|march|april|may|june|july|august|september|october|november|december"

Definition at line 252 of file date_parse.c.

◆ ref_hash

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

Definition at line 44 of file date_parse.c.

◆ REGCOMP

#define REGCOMP (   pat,
  opt 
)
Value:
do { \
if (NIL_P(pat)) \
pat = regcomp(pat##_source, sizeof pat##_source - 1, opt); \
} while (0)

Definition at line 284 of file date_parse.c.

◆ REGCOMP_0

#define REGCOMP_0 (   pat)    REGCOMP(pat, 0)

Definition at line 290 of file date_parse.c.

◆ REGCOMP_I

#define REGCOMP_I (   pat)    REGCOMP(pat, ONIG_OPTION_IGNORECASE)

Definition at line 291 of file date_parse.c.

◆ set_hash

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

Definition at line 43 of file date_parse.c.

◆ sizeof_array

#define sizeof_array (   o)    (sizeof o / sizeof o[0])

Definition at line 15 of file date_parse.c.

◆ SNUM [1/12]

#define SNUM   14

◆ SNUM [2/12]

#define SNUM   17

◆ SNUM [3/12]

#define SNUM   5

◆ SNUM [4/12]

#define SNUM   8

◆ SNUM [5/12]

#define SNUM   8

◆ SNUM [6/12]

#define SNUM   5

◆ SNUM [7/12]

#define SNUM   4

◆ SNUM [8/12]

#define SNUM   8

◆ SNUM [9/12]

#define SNUM   8

◆ SNUM [10/12]

#define SNUM   8

◆ SNUM [11/12]

#define SNUM   7

◆ SNUM [12/12]

#define SNUM   9

◆ str2num

#define str2num (   s)    rb_str_to_inum(s, 10, 0)

Definition at line 48 of file date_parse.c.

◆ SUBS

#define SUBS (   s,
  p,
 
)
Value:
do { \
return subx(s, asp_string(), p, hash, c); \
} while (0)

Definition at line 335 of file date_parse.c.

Function Documentation

◆ date_zone_to_diff()

VALUE date_zone_to_diff ( VALUE  str)

Definition at line 411 of file date_parse.c.

References Qnil, RSTRING_LEN, RSTRING_PTR, and str.

◆ rb_int_positive_pow()

RUBY_EXTERN VALUE rb_int_positive_pow ( long  x,
unsigned long  y 
)

Definition at line 3898 of file numeric.c.

◆ ruby_scan_digits()

RUBY_EXTERN unsigned long ruby_scan_digits ( const char *  str,
ssize_t  len,
int  base,
size_t *  retlen,
int *  overflow 
)

Definition at line 98 of file util.c.

DateData::c
struct ComplexDateData c
Definition: date_core.c:297
asp_string
#define asp_string()
Definition: date_parse.c:61
NIL_P
#define NIL_P
Definition: special_consts.h:46
DateData::s
struct SimpleDateData s
Definition: date_core.c:296