Ruby  2.4.2p198(2017-09-14revision59899)
Macros | Typedefs | Functions | Variables
time.c File Reference
#include "internal.h"
#include <sys/types.h>
#include <time.h>
#include <errno.h>
#include <float.h>
#include <math.h>
#include "timev.h"
Include dependency graph for time.c:

Go to the source code of this file.

Macros

#define _DEFAULT_SOURCE
 
#define _BSD_SOURCE
 
#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 VTM_WDAY_INITVAL   (7)
 
#define VTM_ISDST_INITVAL   (3)
 
#define TO_GMT_INITVAL   (3)
 
#define ne(x, y)   (!eq((x),(y)))
 
#define lt(x, y)   (cmp((x),(y)) < 0)
 
#define gt(x, y)   (cmp((x),(y)) > 0)
 
#define le(x, y)   (cmp((x),(y)) <= 0)
 
#define ge(x, y)   (cmp((x),(y)) >= 0)
 
#define div(x, y)   (rb_funcall((x), id_div, 1, (y)))
 
#define neg(x)   (sub(INT2FIX(0), (x)))
 
#define mulquo(x, y, z)   (((y) == (z)) ? (x) : quo(mul((x),(y)),(z)))
 
#define WIDEVALUE_IS_WIDER   0
 
#define UWIDEINT_MAX   ULONG_MAX
 
#define WIDEINT_MAX   LONG_MAX
 
#define WIDEINT_MIN   LONG_MIN
 
#define FIXWINT_P(v)   FIXNUM_P(v)
 
#define FIXWV_MAX   FIXNUM_MAX
 
#define FIXWV_MIN   FIXNUM_MIN
 
#define FIXWVABLE(i)   FIXABLE(i)
 
#define WINT2FIXWV(i)   WIDEVAL_WRAP(LONG2FIX(i))
 
#define FIXWV2WINT(w)   FIX2LONG(WIDEVAL_GET(w))
 
#define POSFIXWVABLE(wi)   ((wi) < FIXWV_MAX+1)
 
#define NEGFIXWVABLE(wi)   ((wi) >= FIXWV_MIN)
 
#define FIXWV_P(w)   FIXWINT_P(WIDEVAL_GET(w))
 
#define MUL_OVERFLOW_FIXWV_P(a, b)   MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXWV_MIN, FIXWV_MAX)
 
#define WIDEVAL_WRAP(v)   (v)
 
#define WIDEVAL_GET(w)   (w)
 
#define WINT2WV(wi)   WIDEVAL_WRAP(LONG2NUM(wi))
 
#define wne(x, y)   (!weq((x),(y)))
 
#define wlt(x, y)   (wcmp((x),(y)) < 0)
 
#define wgt(x, y)   (wcmp((x),(y)) > 0)
 
#define wle(x, y)   (wcmp((x),(y)) <= 0)
 
#define wge(x, y)   (wcmp((x),(y)) >= 0)
 
#define wmulquo(x, y, z)   ((WIDEVAL_GET(y) == WIDEVAL_GET(z)) ? (x) : wquo(wmul((x),(y)),(z)))
 
#define wmulquoll(x, y, z)   (((y) == (z)) ? (x) : wquo(wmul((x),WINT2WV(y)),WINT2WV(z)))
 
#define TIMET2WV(t)   timet2wv(t)
 
#define WV2TIMET(t)   wv2timet(t)
 
#define leap_year_v_p(y)   leap_year_p(NUM2LONG(mod((y), INT2FIX(400))))
 
#define LOCALTIME(tm, result)   (tzset(),rb_localtime_r((tm), &(result)))
 
#define GMTIME(tm, result)   rb_gmtime_r((tm), &(result))
 
#define GetTimeval(obj, tobj)   ((tobj) = get_timeval(obj))
 
#define GetNewTimeval(obj, tobj)   ((tobj) = get_new_timeval(obj))
 
#define IsTimeval(obj)   rb_typeddata_is_kind_of((obj), &time_data_type)
 
#define TIME_INIT_P(tobj)   ((tobj)->gmt != TO_GMT_INITVAL)
 
#define TIME_UTC_P(tobj)   ((tobj)->gmt == 1)
 
#define TIME_SET_UTC(tobj)   ((tobj)->gmt = 1)
 
#define TIME_LOCALTIME_P(tobj)   ((tobj)->gmt == 0)
 
#define TIME_SET_LOCALTIME(tobj)   ((tobj)->gmt = 0)
 
#define TIME_FIXOFF_P(tobj)   ((tobj)->gmt == 2)
 
#define TIME_SET_FIXOFF(tobj, off)
 
#define TIME_COPY_GMT(tobj1, tobj2)
 
#define MAKE_TM(time, tobj)
 
#define validate_vtm_range(mem, b, e)
 
#define DEBUG_REPORT_GUESSRANGE
 
#define DEBUG_FIND_TIME_NUMGUESS_INC
 
#define GUESS(p)   (DEBUG_FIND_TIME_NUMGUESS_INC (utc_p ? gmtime_with_leapsecond((p), &result) : LOCALTIME((p), result)))
 
#define strftimev(fmt, time, enc)   strftime_cstr((fmt), rb_strlen_lit(fmt), (time), (enc))
 
#define time_succ   rb_time_succ
 
#define wday_p(n)
 
#define get_attr(attr, iffound)
 
#define rb_intern(str)   rb_intern_const(str)
 

Typedefs

typedef unsigned long uwideint_t
 
typedef long wideint_t
 
typedef VALUE WIDEVALUE
 
typedef SIGNED_VALUE SIGNED_WIDEVALUE
 
typedef WIDEVALUE wideval_t
 

Functions

static int eq (VALUE x, VALUE y)
 
static int cmp (VALUE x, VALUE y)
 
static VALUE add (VALUE x, VALUE y)
 
static VALUE sub (VALUE x, VALUE y)
 
static VALUE mul (VALUE x, VALUE y)
 
static VALUE mod (VALUE x, VALUE y)
 
static VALUE quo (VALUE x, VALUE y)
 
static void divmodv (VALUE n, VALUE d, VALUE *q, VALUE *r)
 
static VALUE w2v (wideval_t w)
 
static wideval_t v2w (VALUE v)
 
static int weq (wideval_t wx, wideval_t wy)
 
static int wcmp (wideval_t wx, wideval_t wy)
 
static wideval_t wadd (wideval_t wx, wideval_t wy)
 
static wideval_t wsub (wideval_t wx, wideval_t wy)
 
static wideval_t wmul (wideval_t wx, wideval_t wy)
 
static wideval_t wquo (wideval_t wx, wideval_t wy)
 
static void wdivmod (wideval_t wn, wideval_t wd, wideval_t *wq, wideval_t *wr)
 
static void wmuldivmod (wideval_t wx, wideval_t wy, wideval_t wz, wideval_t *wq, wideval_t *wr)
 
static wideval_t wdiv (wideval_t wx, wideval_t wy)
 
static wideval_t wmod (wideval_t wx, wideval_t wy)
 
static VALUE num_exact (VALUE v)
 
static wideval_t rb_time_magnify (wideval_t w)
 
static wideval_t rb_time_unmagnify (wideval_t w)
 
static VALUE rb_time_unmagnify_to_float (wideval_t w)
 
static void split_second (wideval_t timew, wideval_t *timew_p, VALUE *subsecx_p)
 
static wideval_t timet2wv (time_t t)
 
static time_t wv2timet (wideval_t w)
 
static VALUE time_utc_offset _ ((VALUE))
 
static int obj2int (VALUE obj)
 
static uint32_t obj2ubits (VALUE obj, size_t bits)
 
static VALUE obj2vint (VALUE obj)
 
static uint32_t month_arg (VALUE arg)
 
static VALUE validate_utc_offset (VALUE utc_offset)
 
static VALUE validate_zone_name (VALUE zone_name)
 
static void validate_vtm (struct vtm *vtm)
 
static uint32_t obj2subsecx (VALUE obj, VALUE *subsecx)
 
static VALUE time_gmtime (VALUE)
 
static VALUE time_localtime (VALUE)
 
static VALUE time_fixoff (VALUE)
 
static time_t timegm_noleapsecond (struct tm *tm)
 
static int tmcmp (struct tm *a, struct tm *b)
 
static int vtmcmp (struct vtm *a, struct vtm *b)
 
static const char * find_time_t (struct tm *tptr, int utc_p, time_t *tp)
 
static struct vtm * localtimew (wideval_t timew, struct vtm *result)
 
static int leap_year_p (long y)
 
static struct tm * rb_localtime_r (const time_t *t, struct tm *result)
 
static struct tm * rb_gmtime_r (const time_t *t, struct tm *result)
 
static int calc_tm_yday (long tm_year, int tm_mon, int tm_mday)
 
static wideval_t timegmw_noleapsecond (struct vtm *vtm)
 
static int zone_str_update (st_data_t *key, st_data_t *value, st_data_t arg, int existing)
 
static const char * zone_str (const char *s)
 
static void gmtimew_noleapsecond (wideval_t timew, struct vtm *vtm)
 
static struct tm * gmtime_with_leapsecond (const time_t *timep, struct tm *result)
 
static void init_leap_second_info (void)
 
static wideval_t timegmw (struct vtm *vtm)
 
static struct vtm * gmtimew (wideval_t timew, struct vtm *result)
 
static struct tm * localtime_with_gmtoff_zone (const time_t *t, struct tm *result, long *gmtoff, const char **zone)
 
static int calc_wday (int year, int month, int day)
 
static VALUE guess_local_offset (struct vtm *vtm_utc, int *isdst_ret, const char **zone_ret)
 
static VALUE small_vtm_sub (struct vtm *vtm1, struct vtm *vtm2)
 
static wideval_t timelocalw (struct vtm *vtm)
 
static int timew_out_of_timet_range (wideval_t timew)
 
 PACKED_STRUCT_UNALIGNED (struct time_object { wideval_t timew;struct vtm vtm;uint8_t gmt:3;uint8_t tm_got:1;})
 
static VALUE time_get_tm (VALUE, struct time_object *)
 
static void time_mark (void *ptr)
 
static size_t time_memsize (const void *tobj)
 
static VALUE time_s_alloc (VALUE klass)
 
static struct time_object * get_timeval (VALUE obj)
 
static struct time_object * get_new_timeval (VALUE obj)
 
static void time_modify (VALUE time)
 
static wideval_t timespec2timew (struct timespec *ts)
 
static struct timespec timew2timespec (wideval_t timew)
 
static struct timespectimew2timespec_exact (wideval_t timew, struct timespec *ts)
 
void rb_timespec_now (struct timespec *ts)
 
static VALUE time_init_0 (VALUE time)
 
static VALUE time_set_utc_offset (VALUE time, VALUE off)
 
static void vtm_add_offset (struct vtm *vtm, VALUE off)
 
static VALUE utc_offset_arg (VALUE arg)
 
static VALUE time_init_1 (int argc, VALUE *argv, VALUE time)
 
static VALUE time_init (int argc, VALUE *argv, VALUE time)
 
static void time_overflow_p (time_t *secp, long *nsecp)
 
static wideval_t nsec2timew (time_t sec, long nsec)
 
static VALUE time_new_timew (VALUE klass, wideval_t timew)
 
VALUE rb_time_new (time_t sec, long usec)
 
VALUE rb_time_nano_new (time_t sec, long nsec)
 
VALUE rb_time_timespec_new (const struct timespec *ts, int offset)
 Returns a time object with UTC/localtime/fixed offset. More...
 
VALUE rb_time_num_new (VALUE timev, VALUE off)
 
static struct timespec time_timespec (VALUE num, int interval)
 
static struct timeval time_timeval (VALUE num, int interval)
 
struct timeval rb_time_interval (VALUE num)
 
struct timeval rb_time_timeval (VALUE time)
 
struct timespec rb_time_timespec (VALUE time)
 
static VALUE time_s_now (VALUE klass)
 
static VALUE time_s_at (int argc, VALUE *argv, VALUE klass)
 
static VALUE usec2subsecx (VALUE obj)
 
static void time_arg (int argc, VALUE *argv, struct vtm *vtm)
 
static VALUE time_utc_or_local (int argc, VALUE *argv, int utc_p, VALUE klass)
 
static VALUE time_s_mkutc (int argc, VALUE *argv, VALUE klass)
 
static VALUE time_s_mktime (int argc, VALUE *argv, VALUE klass)
 
static VALUE time_to_i (VALUE time)
 
static VALUE time_to_f (VALUE time)
 
static VALUE time_to_r (VALUE time)
 
static VALUE time_usec (VALUE time)
 
static VALUE time_nsec (VALUE time)
 
static VALUE time_subsec (VALUE time)
 
static VALUE time_cmp (VALUE time1, VALUE time2)
 
static VALUE time_eql (VALUE time1, VALUE time2)
 
static VALUE time_utc_p (VALUE time)
 
static VALUE time_hash (VALUE time)
 
static VALUE time_init_copy (VALUE copy, VALUE time)
 
static VALUE time_dup (VALUE time)
 
static VALUE time_localtime_m (int argc, VALUE *argv, VALUE time)
 
static VALUE time_getlocaltime (int argc, VALUE *argv, VALUE time)
 
static VALUE time_getgmtime (VALUE time)
 
static VALUE strftime_cstr (const char *fmt, size_t len, VALUE time, rb_encoding *enc)
 
static VALUE time_asctime (VALUE time)
 
static VALUE time_to_s (VALUE time)
 
static VALUE time_add (struct time_object *tobj, VALUE offset, int sign)
 
static VALUE time_plus (VALUE time1, VALUE time2)
 
static VALUE time_minus (VALUE time1, VALUE time2)
 
VALUE rb_time_succ (VALUE time)
 
static VALUE time_round (int argc, VALUE *argv, VALUE time)
 
static VALUE time_sec (VALUE time)
 
static VALUE time_min (VALUE time)
 
static VALUE time_hour (VALUE time)
 
static VALUE time_mday (VALUE time)
 
static VALUE time_mon (VALUE time)
 
static VALUE time_year (VALUE time)
 
static VALUE time_wday (VALUE time)
 
static VALUE time_sunday (VALUE time)
 
static VALUE time_monday (VALUE time)
 
static VALUE time_tuesday (VALUE time)
 
static VALUE time_wednesday (VALUE time)
 
static VALUE time_thursday (VALUE time)
 
static VALUE time_friday (VALUE time)
 
static VALUE time_saturday (VALUE time)
 
static VALUE time_yday (VALUE time)
 
static VALUE time_isdst (VALUE time)
 
static VALUE time_zone_name (const char *zone)
 
static VALUE time_zone (VALUE time)
 
static VALUE time_utc_offset (VALUE time)
 
static VALUE time_to_a (VALUE time)
 
static VALUE rb_strftime_alloc (const char *format, size_t format_len, rb_encoding *enc, struct vtm *vtm, wideval_t timew, int gmt)
 
static VALUE time_strftime (VALUE time, VALUE format)
 
static VALUE time_mdump (VALUE time)
 
static VALUE time_dump (int argc, VALUE *argv, VALUE time)
 
static VALUE time_mload (VALUE time, VALUE str)
 
static VALUE time_load (VALUE klass, VALUE str)
 
void Init_Time (void)
 

Variables

static ID id_divmod
 
static ID id_mul
 
static ID id_submicro
 
static ID id_nano_num
 
static ID id_nano_den
 
static ID id_offset
 
static ID id_zone
 
static ID id_eq
 
static ID id_ne
 
static ID id_quo
 
static ID id_div
 
static ID id_cmp
 
VALUE rb_cTime
 
static const int common_year_yday_offset []
 
static const int leap_year_yday_offset []
 
static const int common_year_days_in_month []
 
static const int leap_year_days_in_month []
 
static st_tablezone_table
 
static long this_year = 0
 
static time_t known_leap_seconds_limit
 
static int number_of_leap_seconds_known
 
static int compat_common_month_table [12][7]
 
static int compat_leap_month_table [7]
 
static const rb_data_type_t time_data_type
 
static const char months [][4]
 

Macro Definition Documentation

◆ _BSD_SOURCE

#define _BSD_SOURCE

Definition at line 13 of file time.c.

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE

Definition at line 12 of file time.c.

◆ DEBUG_FIND_TIME_NUMGUESS_INC

#define DEBUG_FIND_TIME_NUMGUESS_INC

Definition at line 2638 of file time.c.

◆ DEBUG_REPORT_GUESSRANGE

#define DEBUG_REPORT_GUESSRANGE

Definition at line 2626 of file time.c.

Referenced by find_time_t().

◆ DIV

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

Definition at line 41 of file time.c.

Referenced by timegm_noleapsecond(), and timegmw_noleapsecond().

◆ div

#define div (   x,
 
)    (rb_funcall((x), id_div, 1, (y)))

Definition at line 106 of file time.c.

Referenced by time_mdump(), and wdiv().

◆ FIXWINT_P

#define FIXWINT_P (   v)    FIXNUM_P(v)

Definition at line 199 of file time.c.

◆ FIXWV2WINT

#define FIXWV2WINT (   w)    FIX2LONG(WIDEVAL_GET(w))

◆ FIXWV_MAX

#define FIXWV_MAX   FIXNUM_MAX

Definition at line 200 of file time.c.

Referenced by timet2wv(), and w2v().

◆ FIXWV_MIN

#define FIXWV_MIN   FIXNUM_MIN

Definition at line 201 of file time.c.

Referenced by timet2wv(), and w2v().

◆ FIXWV_P

#define FIXWV_P (   w)    FIXWINT_P(WIDEVAL_GET(w))

◆ FIXWVABLE

#define FIXWVABLE (   i)    FIXABLE(i)

Definition at line 202 of file time.c.

◆ ge

#define ge (   x,
 
)    (cmp((x),(y)) >= 0)

Definition at line 73 of file time.c.

Referenced by iseq_specialized_instruction(), validate_utc_offset(), and validate_vtm().

◆ get_attr

#define get_attr (   attr,
  iffound 
)
Value:
attr = rb_attr_delete(str, id_##attr); \
if (!NIL_P(attr)) { \
iffound; \
}
VALUE rb_attr_delete(VALUE, ID)
Definition: variable.c:1315
#define NIL_P(v)
Definition: ruby.h:451

Referenced by time_mload().

◆ GetNewTimeval

#define GetNewTimeval (   obj,
  tobj 
)    ((tobj) = get_new_timeval(obj))

Definition at line 1602 of file time.c.

Referenced by time_init_0(), time_init_1(), time_init_copy(), and time_mload().

◆ GetTimeval

#define GetTimeval (   obj,
  tobj 
)    ((tobj) = get_timeval(obj))

◆ GMTIME

#define GMTIME (   tm,
  result 
)    rb_gmtime_r((tm), &(result))

Definition at line 696 of file time.c.

Referenced by gmtime_with_leapsecond(), and localtime_with_gmtoff_zone().

◆ gt

#define gt (   x,
 
)    (cmp((x),(y)) > 0)

Definition at line 71 of file time.c.

Referenced by iseq_specialized_instruction(), and timegmw().

◆ GUESS

#define GUESS (   p)    (DEBUG_FIND_TIME_NUMGUESS_INC (utc_p ? gmtime_with_leapsecond((p), &result) : LOCALTIME((p), result)))

Referenced by find_time_t().

◆ IsTimeval

#define IsTimeval (   obj)    rb_typeddata_is_kind_of((obj), &time_data_type)

◆ le

#define le (   x,
 
)    (cmp((x),(y)) <= 0)

◆ leap_year_v_p

#define leap_year_v_p (   y)    leap_year_p(NUM2LONG(mod((y), INT2FIX(400))))

Definition at line 644 of file time.c.

Referenced by vtm_add_offset().

◆ LOCALTIME

#define LOCALTIME (   tm,
  result 
)    (tzset(),rb_localtime_r((tm), &(result)))

Definition at line 677 of file time.c.

Referenced by find_time_t(), gmtime_with_leapsecond(), and localtime_with_gmtoff_zone().

◆ lt

#define lt (   x,
 
)    (cmp((x),(y)) < 0)

◆ MAKE_TM

#define MAKE_TM (   time,
  tobj 
)
Value:
do { \
if ((tobj)->tm_got == 0) { \
time_get_tm((time), (tobj)); \
} \
} while (0)

Definition at line 1625 of file time.c.

Referenced by strftime_cstr(), time_hour(), time_isdst(), time_mday(), time_min(), time_mon(), time_sec(), time_strftime(), time_to_a(), time_utc_offset(), time_wday(), time_yday(), time_year(), and time_zone().

◆ MOD

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

Definition at line 42 of file time.c.

Referenced by calc_tm_yday().

◆ MUL_OVERFLOW_FIXWV_P

#define MUL_OVERFLOW_FIXWV_P (   a,
 
)    MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXWV_MIN, FIXWV_MAX)

Definition at line 210 of file time.c.

Referenced by wmul().

◆ mulquo

#define mulquo (   x,
  y,
 
)    (((y) == (z)) ? (x) : quo(mul((x),(y)),(z)))

Definition at line 144 of file time.c.

Referenced by time_mdump(), time_mload(), timew2timespec(), timew2timespec_exact(), and usec2subsecx().

◆ NDIV

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

Definition at line 39 of file time.c.

Referenced by rb_time_new(), and time_overflow_p().

◆ ne

#define ne (   x,
 
)    (!eq((x),(y)))

Definition at line 69 of file time.c.

Referenced by add_ensure_range(), small_vtm_sub(), VpAlloc(), VpCtoV(), VpDtoV(), and vtmcmp().

◆ neg

#define neg (   x)    (sub(INT2FIX(0), (x)))

◆ NEGFIXWVABLE

#define NEGFIXWVABLE (   wi)    ((wi) >= FIXWV_MIN)

Definition at line 208 of file time.c.

◆ NMOD

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

Definition at line 40 of file time.c.

◆ POSFIXWVABLE

#define POSFIXWVABLE (   wi)    ((wi) < FIXWV_MAX+1)

Definition at line 207 of file time.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by Init_Time(), num_exact(), and time_init_1().

◆ strftimev

#define strftimev (   fmt,
  time,
  enc 
)    strftime_cstr((fmt), rb_strlen_lit(fmt), (time), (enc))

Definition at line 3533 of file time.c.

Referenced by time_asctime(), and time_to_s().

◆ TIME_COPY_GMT

#define TIME_COPY_GMT (   tobj1,
  tobj2 
)
Value:
((tobj1)->gmt = (tobj2)->gmt, \
(tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \
(tobj1)->vtm.zone = (tobj2)->vtm.zone)

Definition at line 1619 of file time.c.

Referenced by rb_time_succ(), and time_s_at().

◆ TIME_FIXOFF_P

#define TIME_FIXOFF_P (   tobj)    ((tobj)->gmt == 2)

Definition at line 1613 of file time.c.

Referenced by time_add(), time_fixoff(), and time_get_tm().

◆ TIME_INIT_P

#define TIME_INIT_P (   tobj)    ((tobj)->gmt != TO_GMT_INITVAL)

Definition at line 1605 of file time.c.

Referenced by get_new_timeval(), and get_timeval().

◆ TIME_LOCALTIME_P

#define TIME_LOCALTIME_P (   tobj)    ((tobj)->gmt == 0)

Definition at line 1610 of file time.c.

Referenced by time_localtime().

◆ TIME_SET_FIXOFF

#define TIME_SET_FIXOFF (   tobj,
  off 
)
Value:
((tobj)->gmt = 2, \
(tobj)->vtm.utc_offset = (off), \
(tobj)->vtm.zone = NULL)
#define NULL
Definition: _sdbm.c:102

Definition at line 1614 of file time.c.

Referenced by rb_time_timespec_new(), time_add(), time_fixoff(), and time_set_utc_offset().

◆ TIME_SET_LOCALTIME

#define TIME_SET_LOCALTIME (   tobj)    ((tobj)->gmt = 0)

Definition at line 1611 of file time.c.

Referenced by time_localtime().

◆ TIME_SET_UTC

#define TIME_SET_UTC (   tobj)    ((tobj)->gmt = 1)

Definition at line 1608 of file time.c.

Referenced by rb_time_timespec_new(), time_add(), time_gmtime(), and time_mload().

◆ time_succ

#define time_succ   rb_time_succ

Definition at line 3683 of file time.c.

Referenced by Init_Time().

◆ TIME_UTC_P

#define TIME_UTC_P (   tobj)    ((tobj)->gmt == 1)

◆ TIMET2WV

#define TIMET2WV (   t)    timet2wv(t)

Definition at line 595 of file time.c.

Referenced by gmtimew(), init_leap_second_info(), time_mload(), timegmw(), timelocalw(), and timespec2timew().

◆ TO_GMT_INITVAL

#define TO_GMT_INITVAL   (3)

Definition at line 45 of file time.c.

Referenced by time_s_alloc().

◆ UWIDEINT_MAX

#define UWIDEINT_MAX   ULONG_MAX

Definition at line 196 of file time.c.

◆ validate_vtm_range

#define validate_vtm_range (   mem,
  b,
 
)
Value:
((vtm->mem < b || vtm->mem > e) ? \
rb_raise(rb_eArgError, #mem" out of range") : (void)0)
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:2207
VALUE rb_eArgError
Definition: error.c:763

Referenced by validate_vtm().

◆ VTM_ISDST_INITVAL

#define VTM_ISDST_INITVAL   (3)

Definition at line 44 of file time.c.

Referenced by time_arg(), time_init_1(), and timelocalw().

◆ VTM_WDAY_INITVAL

#define VTM_WDAY_INITVAL   (7)

Definition at line 43 of file time.c.

Referenced by time_arg(), and time_init_1().

◆ wday_p

#define wday_p (   n)
Value:
{\
struct time_object *tobj;\
GetTimeval(time, tobj);\
MAKE_TM(time, tobj);\
return (tobj->vtm.wday == (n)) ? Qtrue : Qfalse;\
}
#define Qtrue
Definition: ruby.h:437
#define Qfalse
Definition: ruby.h:436

Definition at line 3915 of file time.c.

Referenced by time_friday(), time_monday(), time_saturday(), time_sunday(), time_thursday(), time_tuesday(), and time_wednesday().

◆ wge

#define wge (   x,
 
)    (wcmp((x),(y)) >= 0)

Definition at line 332 of file time.c.

◆ wgt

#define wgt (   x,
 
)    (wcmp((x),(y)) > 0)

Definition at line 330 of file time.c.

◆ WIDEINT_MAX

#define WIDEINT_MAX   LONG_MAX

Definition at line 197 of file time.c.

◆ WIDEINT_MIN

#define WIDEINT_MIN   LONG_MIN

Definition at line 198 of file time.c.

◆ WIDEVAL_GET

#define WIDEVAL_GET (   w)    (w)

Definition at line 223 of file time.c.

Referenced by w2v(), weq(), and wmuldivmod().

◆ WIDEVAL_WRAP

#define WIDEVAL_WRAP (   v)    (v)

Definition at line 222 of file time.c.

Referenced by v2w(), and w2v().

◆ WIDEVALUE_IS_WIDER

#define WIDEVALUE_IS_WIDER   0

Definition at line 195 of file time.c.

◆ WINT2FIXWV

#define WINT2FIXWV (   i)    WIDEVAL_WRAP(LONG2FIX(i))

◆ WINT2WV

#define WINT2WV (   wi)    WIDEVAL_WRAP(LONG2NUM(wi))

Definition at line 237 of file time.c.

Referenced by gmtimew(), time_nsec(), time_usec(), timegmw(), timespec2timew(), wadd(), wmul(), wquo(), and wsub().

◆ wle

#define wle (   x,
 
)    (wcmp((x),(y)) <= 0)

Definition at line 331 of file time.c.

◆ wlt

#define wlt (   x,
 
)    (wcmp((x),(y)) < 0)

Definition at line 329 of file time.c.

Referenced by gmtimew(), and timegmw().

◆ wmulquo

#define wmulquo (   x,
  y,
 
)    ((WIDEVAL_GET(y) == WIDEVAL_GET(z)) ? (x) : wquo(wmul((x),(y)),(z)))

Definition at line 396 of file time.c.

◆ wmulquoll

#define wmulquoll (   x,
  y,
 
)    (((y) == (z)) ? (x) : wquo(wmul((x),WINT2WV(y)),WINT2WV(z)))

Definition at line 397 of file time.c.

Referenced by time_mload(), time_nsec(), time_s_at(), and timespec2timew().

◆ wne

#define wne (   x,
 
)    (!weq((x),(y)))

Definition at line 328 of file time.c.

◆ WV2TIMET

#define WV2TIMET (   t)    wv2timet(t)

Definition at line 618 of file time.c.

Referenced by gmtimew(), localtimew(), timew2timespec(), and timew2timespec_exact().

Typedef Documentation

◆ SIGNED_WIDEVALUE

Definition at line 194 of file time.c.

◆ uwideint_t

typedef unsigned long uwideint_t

Definition at line 191 of file time.c.

◆ wideint_t

typedef long wideint_t

Definition at line 192 of file time.c.

◆ wideval_t

Definition at line 221 of file time.c.

◆ WIDEVALUE

typedef VALUE WIDEVALUE

Definition at line 193 of file time.c.

Function Documentation

◆ _()

static VALUE time_utc_offset _ ( (VALUE )
static

◆ add()

static VALUE add ( VALUE  x,
VALUE  y 
)
static

◆ calc_tm_yday()

static int calc_tm_yday ( long  tm_year,
int  tm_mon,
int  tm_mday 
)
static

Definition at line 738 of file time.c.

References leap_year_p(), and MOD.

Referenced by find_time_t(), and timegmw_noleapsecond().

◆ calc_wday()

static int calc_wday ( int  year,
int  month,
int  day 
)
static

Definition at line 1255 of file time.c.

Referenced by guess_local_offset().

◆ cmp()

static int cmp ( VALUE  x,
VALUE  y 
)
static

◆ divmodv()

static void divmodv ( VALUE  n,
VALUE  d,
VALUE q,
VALUE r 
)
static

◆ eq()

static int eq ( VALUE  x,
VALUE  y 
)
static

Definition at line 48 of file time.c.

References FIXNUM_P, id_eq, rb_funcall(), and RTEST.

Referenced by init_env(), iseq_specialized_instruction(), and weq().

◆ find_time_t()

static const char * find_time_t ( struct tm *  tptr,
int  utc_p,
time_t *  tp 
)
static

◆ get_new_timeval()

static struct time_object* get_new_timeval ( VALUE  obj)
static

Definition at line 1681 of file time.c.

References PRIsVALUE, rb_eTypeError, rb_obj_class(), rb_raise(), TIME_INIT_P, and TypedData_Get_Struct.

◆ get_timeval()

static struct time_object* get_timeval ( VALUE  obj)
static

Definition at line 1670 of file time.c.

References PRIsVALUE, rb_eTypeError, rb_obj_class(), rb_raise(), TIME_INIT_P, and TypedData_Get_Struct.

◆ gmtime_with_leapsecond()

static struct tm* gmtime_with_leapsecond ( const time_t *  timep,
struct tm *  result 
)
static

◆ gmtimew()

static struct vtm* gmtimew ( wideval_t  timew,
struct vtm *  result 
)
static

◆ gmtimew_noleapsecond()

static void gmtimew_noleapsecond ( wideval_t  timew,
struct vtm *  vtm 
)
static

◆ guess_local_offset()

static VALUE guess_local_offset ( struct vtm *  vtm_utc,
int *  isdst_ret,
const char **  zone_ret 
)
static

◆ init_leap_second_info()

static void init_leap_second_info ( void  )
static

◆ Init_Time()

void Init_Time ( void  )

◆ leap_year_p()

static int leap_year_p ( long  y)
static

◆ localtime_with_gmtoff_zone()

static struct tm * localtime_with_gmtoff_zone ( const time_t *  t,
struct tm *  result,
long *  gmtoff,
const char **  zone 
)
static

Definition at line 1455 of file time.c.

References buf, GMTIME, LOCALTIME, NULL, result, and zone_str().

Referenced by gmtimew(), guess_local_offset(), and localtimew().

◆ localtimew()

static struct vtm * localtimew ( wideval_t  timew,
struct vtm *  result 
)
static

◆ mod()

static VALUE mod ( VALUE  x,
VALUE  y 
)
static

◆ month_arg()

static uint32_t month_arg ( VALUE  arg)
static

Definition at line 2459 of file time.c.

References NIL_P, obj2ubits(), rb_check_string_type(), RSTRING_LEN, RSTRING_PTR, and STRNCASECMP.

Referenced by time_arg(), and time_init_1().

◆ mul()

static VALUE mul ( VALUE  x,
VALUE  y 
)
static

◆ nsec2timew()

static wideval_t nsec2timew ( time_t  sec,
long  nsec 
)
static

◆ num_exact()

static VALUE num_exact ( VALUE  v)
static

◆ obj2int()

static int obj2int ( VALUE  obj)
static

Definition at line 2394 of file time.c.

References FALSE, NUM2INT, rb_str_to_inum(), RB_TYPE_P, and T_STRING.

Referenced by obj2ubits().

◆ obj2subsecx()

static uint32_t obj2subsecx ( VALUE  obj,
VALUE subsecx 
)
static

◆ obj2ubits()

static uint32_t obj2ubits ( VALUE  obj,
size_t  bits 
)
static

Definition at line 2404 of file time.c.

References obj2int(), rb_eArgError, and rb_raise().

Referenced by month_arg(), obj2subsecx(), time_arg(), and time_init_1().

◆ obj2vint()

static VALUE obj2vint ( VALUE  obj)
static

Definition at line 2420 of file time.c.

References FALSE, rb_str_to_inum(), rb_to_int(), RB_TYPE_P, and T_STRING.

Referenced by time_arg(), and time_init_1().

◆ PACKED_STRUCT_UNALIGNED()

PACKED_STRUCT_UNALIGNED ( struct time_object { wideval_t timew;struct vtm vtm;uint8_t gmt:3;uint8_t tm_got:1;}  )

Referenced by localtimew().

◆ quo()

static VALUE quo ( VALUE  x,
VALUE  y 
)
static

◆ rb_gmtime_r()

static struct tm* rb_gmtime_r ( const time_t *  t,
struct tm *  result 
)
static

Definition at line 681 of file time.c.

References gmtime_r(), NULL, and result.

◆ rb_localtime_r()

static struct tm* rb_localtime_r ( const time_t *  t,
struct tm *  result 
)
static

Definition at line 647 of file time.c.

References localtime_r(), NULL, and result.

◆ rb_strftime_alloc()

static VALUE rb_strftime_alloc ( const char *  format,
size_t  format_len,
rb_encoding enc,
struct vtm *  vtm,
wideval_t  timew,
int  gmt 
)
static

◆ rb_time_interval()

struct timeval rb_time_interval ( VALUE  num)

Definition at line 2286 of file time.c.

References time_timeval(), and TRUE.

Referenced by get_timeout(), io_wait_readwrite(), rb_f_select(), rb_f_sleep(), and rb_mutex_sleep().

◆ rb_time_magnify()

static wideval_t rb_time_magnify ( wideval_t  w)
static

◆ rb_time_nano_new()

VALUE rb_time_nano_new ( time_t  sec,
long  nsec 
)

Definition at line 2157 of file time.c.

References nsec2timew(), rb_cTime, and time_new_timew().

Referenced by stat_atime(), stat_ctime(), and stat_mtime().

◆ rb_time_new()

VALUE rb_time_new ( time_t  sec,
long  usec 
)

Definition at line 2130 of file time.c.

References NDIV, nsec2timew(), rb_cTime, rb_eRangeError, rb_raise(), and time_new_timew().

Referenced by rb_gzfile_mtime().

◆ rb_time_num_new()

VALUE rb_time_num_new ( VALUE  timev,
VALUE  off 
)

◆ rb_time_succ()

VALUE rb_time_succ ( VALUE  time)

Definition at line 3670 of file time.c.

References GetTimeval, rb_cTime, rb_warn(), TIME_COPY_GMT, time_new_timew(), TIME_SCALE, wadd(), and WINT2FIXWV.

◆ rb_time_timespec()

struct timespec rb_time_timespec ( VALUE  time)

Definition at line 2309 of file time.c.

References FALSE, GetTimeval, IsTimeval, time_timespec(), and timew2timespec().

Referenced by rb_file_s_utime().

◆ rb_time_timespec_new()

VALUE rb_time_timespec_new ( const struct timespec ts,
int  offset 
)

Returns a time object with UTC/localtime/fixed offset.

offset is -86400 < fixoff < 86400 or INT_MAX (localtime) or INT_MAX-1 (utc)

Definition at line 2168 of file time.c.

References GetTimeval, INT2FIX, nsec2timew(), rb_cTime, rb_eArgError, rb_raise(), time_new_timew(), TIME_SET_FIXOFF, TIME_SET_UTC, timespec::tv_nsec, and timespec::tv_sec.

◆ rb_time_timeval()

struct timeval rb_time_timeval ( VALUE  time)

◆ rb_time_unmagnify()

static wideval_t rb_time_unmagnify ( wideval_t  w)
static

Definition at line 538 of file time.c.

References TIME_SCALE, WINT2FIXWV, and wquo().

Referenced by guess_local_offset(), init_leap_second_info(), rb_strftime_alloc(), time_round(), and time_to_r().

◆ rb_time_unmagnify_to_float()

static VALUE rb_time_unmagnify_to_float ( wideval_t  w)
static

Definition at line 544 of file time.c.

References DBL2NUM, FIXWV2WINT, FIXWV_P, INT2FIX, quo(), rb_Float(), RB_TYPE_P, T_RATIONAL, TIME_SCALE, and w2v().

Referenced by time_minus(), and time_to_f().

◆ rb_timespec_now()

void rb_timespec_now ( struct timespec ts)

◆ small_vtm_sub()

static VALUE small_vtm_sub ( struct vtm *  vtm1,
struct vtm *  vtm2 
)
static

Definition at line 1355 of file time.c.

References INT2FIX, lt, and ne.

Referenced by timelocalw().

◆ split_second()

static void split_second ( wideval_t  timew,
wideval_t timew_p,
VALUE subsecx_p 
)
static

◆ strftime_cstr()

static VALUE strftime_cstr ( const char *  fmt,
size_t  len,
VALUE  time,
rb_encoding enc 
)
static

Definition at line 4219 of file time.c.

References GetTimeval, MAKE_TM, rb_eArgError, rb_raise(), rb_strftime_alloc(), and TIME_UTC_P.

Referenced by time_get_tm().

◆ sub()

static VALUE sub ( VALUE  x,
VALUE  y 
)
static

◆ time_add()

static VALUE time_add ( struct time_object *  tobj,
VALUE  offset,
int  sign 
)
static

◆ time_arg()

static void time_arg ( int  argc,
VALUE argv,
struct vtm *  vtm 
)
static

◆ time_asctime()

static VALUE time_asctime ( VALUE  time)
static

Definition at line 3547 of file time.c.

References rb_usascii_encoding(), and strftimev.

Referenced by Init_Time().

◆ time_cmp()

static VALUE time_cmp ( VALUE  time1,
VALUE  time2 
)
static

Definition at line 3216 of file time.c.

References GetTimeval, INT2FIX, IsTimeval, rb_invcmp(), and wcmp().

Referenced by Init_Time().

◆ time_dump()

static VALUE time_dump ( int  argc,
VALUE argv,
VALUE  time 
)
static

Definition at line 4551 of file time.c.

References rb_scan_args(), and time_mdump().

Referenced by Init_Time().

◆ time_dup()

static VALUE time_dup ( VALUE  time)
static

Definition at line 3316 of file time.c.

References rb_obj_class(), time_init_copy(), and time_s_alloc().

Referenced by time_getgmtime(), and time_getlocaltime().

◆ time_eql()

static VALUE time_eql ( VALUE  time1,
VALUE  time2 
)
static

Definition at line 3243 of file time.c.

References GetTimeval, IsTimeval, Qfalse, rb_equal(), and w2v().

Referenced by Init_Time().

◆ time_fixoff()

static VALUE time_fixoff ( VALUE  time)
static

◆ time_friday()

static VALUE time_friday ( VALUE  time)
static

Definition at line 4013 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_get_tm()

static VALUE time_get_tm ( VALUE  time,
struct time_object *  tobj 
)
static

◆ time_getgmtime()

static VALUE time_getgmtime ( VALUE  time)
static

Definition at line 3519 of file time.c.

References time_dup(), and time_gmtime().

Referenced by Init_Time().

◆ time_getlocaltime()

static VALUE time_getlocaltime ( int  argc,
VALUE argv,
VALUE  time 
)
static

◆ time_gmtime()

static VALUE time_gmtime ( VALUE  time)
static

◆ time_hash()

static VALUE time_hash ( VALUE  time)
static

Definition at line 3293 of file time.c.

References GetTimeval, rb_hash(), and w2v().

Referenced by Init_Time().

◆ time_hour()

static VALUE time_hour ( VALUE  time)
static

Definition at line 3814 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_init()

static VALUE time_init ( int  argc,
VALUE argv,
VALUE  time 
)
static

Definition at line 2067 of file time.c.

References time_init_0(), and time_init_1().

Referenced by Init_Time().

◆ time_init_0()

static VALUE time_init_0 ( VALUE  time)
static

Definition at line 1762 of file time.c.

References GetNewTimeval, rb_timespec_now(), time_modify(), timespec2timew(), and WINT2FIXWV.

Referenced by time_init().

◆ time_init_1()

static VALUE time_init_1 ( int  argc,
VALUE argv,
VALUE  time 
)
static

◆ time_init_copy()

static VALUE time_init_copy ( VALUE  copy,
VALUE  time 
)
static

Definition at line 3303 of file time.c.

References GetNewTimeval, GetTimeval, MEMCPY, and OBJ_INIT_COPY.

Referenced by Init_Time(), and time_dup().

◆ time_isdst()

static VALUE time_isdst ( VALUE  time)
static

Definition at line 4080 of file time.c.

References GetTimeval, MAKE_TM, Qfalse, and Qtrue.

Referenced by Init_Time().

◆ time_load()

static VALUE time_load ( VALUE  klass,
VALUE  str 
)
static

Definition at line 4685 of file time.c.

References time_mload(), and time_s_alloc().

Referenced by Init_Time().

◆ time_localtime()

static VALUE time_localtime ( VALUE  time)
static

◆ time_localtime_m()

static VALUE time_localtime_m ( int  argc,
VALUE argv,
VALUE  time 
)
static

◆ time_mark()

static void time_mark ( void *  ptr)
static

Definition at line 1633 of file time.c.

References FIXWV_P, rb_gc_mark(), and w2v().

◆ time_mday()

static VALUE time_mday ( VALUE  time)
static

Definition at line 3836 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_mdump()

static VALUE time_mdump ( VALUE  time)
static

◆ time_memsize()

static size_t time_memsize ( const void *  tobj)
static

Definition at line 1644 of file time.c.

◆ time_min()

static VALUE time_min ( VALUE  time)
static

Definition at line 3794 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_minus()

static VALUE time_minus ( VALUE  time1,
VALUE  time2 
)
static

Definition at line 3640 of file time.c.

References GetTimeval, IsTimeval, rb_Float(), rb_time_unmagnify_to_float(), time_add(), and wsub().

Referenced by Init_Time().

◆ time_mload()

static VALUE time_mload ( VALUE  time,
VALUE  str 
)
static

◆ time_modify()

static void time_modify ( VALUE  time)
static

◆ time_mon()

static VALUE time_mon ( VALUE  time)
static

Definition at line 3858 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_monday()

static VALUE time_monday ( VALUE  time)
static

Definition at line 3949 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_new_timew()

static VALUE time_new_timew ( VALUE  klass,
wideval_t  timew 
)
static

◆ time_nsec()

static VALUE time_nsec ( VALUE  time)
static

Definition at line 3154 of file time.c.

References GetTimeval, rb_to_int(), TIME_SCALE, w2v(), WINT2WV, wmod(), and wmulquoll.

Referenced by Init_Time().

◆ time_overflow_p()

static void time_overflow_p ( time_t *  secp,
long *  nsecp 
)
static

Definition at line 2076 of file time.c.

References NDIV, rb_eArgError, rb_eRangeError, and rb_raise().

Referenced by nsec2timew().

◆ time_plus()

static VALUE time_plus ( VALUE  time1,
VALUE  time2 
)
static

Definition at line 3613 of file time.c.

References GetTimeval, IsTimeval, rb_eTypeError, rb_raise(), and time_add().

Referenced by Init_Time().

◆ time_round()

static VALUE time_round ( int  argc,
VALUE argv,
VALUE  time 
)
static

◆ time_s_alloc()

static VALUE time_s_alloc ( VALUE  klass)
static

Definition at line 1656 of file time.c.

References TO_GMT_INITVAL, TypedData_Make_Struct, and WINT2FIXWV.

Referenced by Init_Time(), time_dup(), time_load(), and time_new_timew().

◆ time_s_at()

static VALUE time_s_at ( int  argc,
VALUE argv,
VALUE  klass 
)
static

◆ time_s_mktime()

static VALUE time_s_mktime ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 3030 of file time.c.

References FALSE, and time_utc_or_local().

Referenced by Init_Time().

◆ time_s_mkutc()

static VALUE time_s_mkutc ( int  argc,
VALUE argv,
VALUE  klass 
)
static

Definition at line 2999 of file time.c.

References time_utc_or_local(), and TRUE.

Referenced by Init_Time().

◆ time_s_now()

static VALUE time_s_now ( VALUE  klass)
static

Definition at line 2333 of file time.c.

References NULL, and rb_class_new_instance().

Referenced by Init_Time().

◆ time_saturday()

static VALUE time_saturday ( VALUE  time)
static

Definition at line 4029 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_sec()

static VALUE time_sec ( VALUE  time)
static

Definition at line 3774 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_set_utc_offset()

static VALUE time_set_utc_offset ( VALUE  time,
VALUE  off 
)
static

◆ time_strftime()

static VALUE time_strftime ( VALUE  time,
VALUE  format 
)
static

◆ time_subsec()

static VALUE time_subsec ( VALUE  time)
static

Definition at line 3182 of file time.c.

References GetTimeval, INT2FIX, quo(), TIME_SCALE, w2v(), WINT2FIXWV, and wmod().

Referenced by Init_Time().

◆ time_sunday()

static VALUE time_sunday ( VALUE  time)
static

Definition at line 3933 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_thursday()

static VALUE time_thursday ( VALUE  time)
static

Definition at line 3997 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_timespec()

static struct timespec time_timespec ( VALUE  num,
int  interval 
)
static

◆ time_timeval()

static struct timeval time_timeval ( VALUE  num,
int  interval 
)
static

◆ time_to_a()

static VALUE time_to_a ( VALUE  time)
static

Definition at line 4181 of file time.c.

References GetTimeval, INT2FIX, MAKE_TM, Qfalse, Qtrue, rb_ary_new3, and time_zone().

Referenced by Init_Time().

◆ time_to_f()

static VALUE time_to_f ( VALUE  time)
static

Definition at line 3073 of file time.c.

References GetTimeval, rb_Float(), and rb_time_unmagnify_to_float().

Referenced by Init_Time().

◆ time_to_i()

static VALUE time_to_i ( VALUE  time)
static

Definition at line 3049 of file time.c.

References GetTimeval, TIME_SCALE, w2v(), wdiv(), and WINT2FIXWV.

Referenced by Init_Time().

◆ time_to_r()

static VALUE time_to_r ( VALUE  time)
static

Definition at line 3097 of file time.c.

References GetTimeval, rb_Rational1, rb_time_unmagnify(), RB_TYPE_P, T_RATIONAL, and w2v().

Referenced by Init_Time().

◆ time_to_s()

static VALUE time_to_s ( VALUE  time)
static

Definition at line 3569 of file time.c.

References GetTimeval, rb_usascii_encoding(), strftimev, and TIME_UTC_P.

Referenced by Init_Time().

◆ time_tuesday()

static VALUE time_tuesday ( VALUE  time)
static

Definition at line 3965 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_usec()

static VALUE time_usec ( VALUE  time)
static

Definition at line 3123 of file time.c.

References GetTimeval, rb_to_int(), TIME_SCALE, w2v(), WINT2FIXWV, WINT2WV, wmod(), and wmuldivmod().

Referenced by Init_Time().

◆ time_utc_offset()

static VALUE time_utc_offset ( VALUE  time)
static

Definition at line 4148 of file time.c.

References GetTimeval, INT2FIX, MAKE_TM, and TIME_UTC_P.

Referenced by Init_Time(), and time_mdump().

◆ time_utc_or_local()

static VALUE time_utc_or_local ( int  argc,
VALUE argv,
int  utc_p,
VALUE  klass 
)
static

Definition at line 2952 of file time.c.

References time_arg(), time_gmtime(), time_localtime(), time_new_timew(), timegmw(), and timelocalw().

Referenced by time_s_mktime(), and time_s_mkutc().

◆ time_utc_p()

static VALUE time_utc_p ( VALUE  time)
static

Definition at line 3274 of file time.c.

References GetTimeval, Qfalse, Qtrue, and TIME_UTC_P.

Referenced by Init_Time().

◆ time_wday()

static VALUE time_wday ( VALUE  time)
static

Definition at line 3906 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_wednesday()

static VALUE time_wednesday ( VALUE  time)
static

Definition at line 3981 of file time.c.

References wday_p.

Referenced by Init_Time().

◆ time_yday()

static VALUE time_yday ( VALUE  time)
static

Definition at line 4045 of file time.c.

References GetTimeval, INT2FIX, and MAKE_TM.

Referenced by Init_Time().

◆ time_year()

static VALUE time_year ( VALUE  time)
static

Definition at line 3878 of file time.c.

References GetTimeval, and MAKE_TM.

Referenced by Init_Time().

◆ time_zone()

static VALUE time_zone ( VALUE  time)
static

Definition at line 4116 of file time.c.

References GetTimeval, MAKE_TM, NULL, Qnil, rb_usascii_str_new_cstr(), TIME_UTC_P, and time_zone_name().

Referenced by Init_Time(), and time_to_a().

◆ time_zone_name()

static VALUE time_zone_name ( const char *  zone)
static

◆ timegm_noleapsecond()

static time_t timegm_noleapsecond ( struct tm *  tm)
static

Definition at line 2595 of file time.c.

References DIV, and leap_year_p().

Referenced by find_time_t().

◆ timegmw()

static wideval_t timegmw ( struct vtm *  vtm)
static

◆ timegmw_noleapsecond()

static wideval_t timegmw_noleapsecond ( struct vtm *  vtm)
static

◆ timelocalw()

static wideval_t timelocalw ( struct vtm *  vtm)
static

◆ timespec2timew()

static wideval_t timespec2timew ( struct timespec ts)
static

Definition at line 1699 of file time.c.

References rb_time_magnify(), TIME_SCALE, TIMET2WV, timespec::tv_nsec, timespec::tv_sec, wadd(), WINT2WV, and wmulquoll.

Referenced by nsec2timew(), and time_init_0().

◆ timet2wv()

static wideval_t timet2wv ( time_t  t)
static

Definition at line 577 of file time.c.

References FIXWV_MAX, FIXWV_MIN, v2w(), and WINT2FIXWV.

◆ timew2timespec()

static struct timespec timew2timespec ( wideval_t  timew)
static

◆ timew2timespec_exact()

static struct timespec* timew2timespec_exact ( wideval_t  timew,
struct timespec ts 
)
static

◆ timew_out_of_timet_range()

static int timew_out_of_timet_range ( wideval_t  timew)
static

Definition at line 1513 of file time.c.

References add(), FIXWV2WINT, FIXWV_P, INT2FIX, le, lt, mul(), TIME_SCALE, and w2v().

Referenced by localtimew(), timew2timespec(), and timew2timespec_exact().

◆ tmcmp()

static int tmcmp ( struct tm *  a,
struct tm *  b 
)
static

Definition at line 2933 of file time.c.

Referenced by find_time_t().

◆ usec2subsecx()

static VALUE usec2subsecx ( VALUE  obj)
static

Definition at line 2449 of file time.c.

References FALSE, INT2FIX, mulquo, num_exact(), rb_str_to_inum(), RB_TYPE_P, T_STRING, and TIME_SCALE.

Referenced by time_arg().

◆ utc_offset_arg()

static VALUE utc_offset_arg ( VALUE  arg)
static

◆ v2w()

static wideval_t v2w ( VALUE  v)
inlinestatic

◆ validate_utc_offset()

static VALUE validate_utc_offset ( VALUE  utc_offset)
static

Definition at line 2488 of file time.c.

References ge, INT2FIX, le, rb_eArgError, and rb_raise().

Referenced by rb_time_num_new(), time_getlocaltime(), time_localtime_m(), time_mload(), and validate_vtm().

◆ validate_vtm()

static void validate_vtm ( struct vtm *  vtm)
static

Definition at line 2503 of file time.c.

References ge, INT2FIX, lt, NIL_P, rb_eArgError, rb_raise(), TIME_SCALE, validate_utc_offset(), and validate_vtm_range.

Referenced by time_arg(), and time_init_1().

◆ validate_zone_name()

static VALUE validate_zone_name ( VALUE  zone_name)
static

Definition at line 2496 of file time.c.

References StringValueCStr.

Referenced by time_mload().

◆ vtm_add_offset()

static void vtm_add_offset ( struct vtm *  vtm,
VALUE  off 
)
static

◆ vtmcmp()

static int vtmcmp ( struct vtm *  a,
struct vtm *  b 
)
static

Definition at line 2912 of file time.c.

References lt, and ne.

Referenced by timelocalw().

◆ w2v()

static VALUE w2v ( wideval_t  w)
inlinestatic

◆ wadd()

static wideval_t wadd ( wideval_t  wx,
wideval_t  wy 
)
static

◆ wcmp()

static int wcmp ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 308 of file time.c.

References FIXWV2WINT, FIXWV_P, id_cmp, rb_cmpint(), rb_funcall(), and w2v().

Referenced by time_cmp().

◆ wdiv()

static wideval_t wdiv ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 462 of file time.c.

References div, v2w(), and w2v().

Referenced by time_to_i().

◆ wdivmod()

static void wdivmod ( wideval_t  wn,
wideval_t  wd,
wideval_t wq,
wideval_t wr 
)
static

Definition at line 439 of file time.c.

References divmodv(), v2w(), and w2v().

Referenced by gmtimew_noleapsecond(), split_second(), and wmuldivmod().

◆ weq()

static int weq ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 295 of file time.c.

References eq(), FIXWV_P, id_eq, rb_funcall(), RTEST, w2v(), and WIDEVAL_GET.

Referenced by timelocalw().

◆ wmod()

static wideval_t wmod ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 472 of file time.c.

References mod(), v2w(), and w2v().

Referenced by time_nsec(), time_subsec(), and time_usec().

◆ wmul()

static wideval_t wmul ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 367 of file time.c.

References FIXWV2WINT, FIXWV_P, mul(), MUL_OVERFLOW_FIXWV_P, v2w(), w2v(), and WINT2WV.

Referenced by rb_time_magnify(), timegmw_noleapsecond(), and wmuldivmod().

◆ wmuldivmod()

static void wmuldivmod ( wideval_t  wx,
wideval_t  wy,
wideval_t  wz,
wideval_t wq,
wideval_t wr 
)
static

Definition at line 451 of file time.c.

References wdivmod(), WIDEVAL_GET, WINT2FIXWV, and wmul().

Referenced by time_usec().

◆ wquo()

static wideval_t wquo ( wideval_t  wx,
wideval_t  wy 
)
static

Definition at line 379 of file time.c.

References FIXWV2WINT, FIXWV_P, quo(), rb_num_zerodiv(), v2w(), w2v(), and WINT2WV.

Referenced by rb_time_unmagnify().

◆ wsub()

static wideval_t wsub ( wideval_t  wx,
wideval_t  wy 
)
static

◆ wv2timet()

static time_t wv2timet ( wideval_t  w)
static

Definition at line 598 of file time.c.

References FIXWV2WINT, FIXWV_P, rb_eRangeError, rb_raise(), and w2v().

◆ zone_str()

static const char* zone_str ( const char *  s)
static

Definition at line 810 of file time.c.

References st_data_t, st_init_strtable, st_update(), and zone_str_update().

Referenced by localtime_with_gmtoff_zone().

◆ zone_str_update()

static int zone_str_update ( st_data_t key,
st_data_t value,
st_data_t  arg,
int  existing 
)
static

Definition at line 795 of file time.c.

References ST_CONTINUE, st_data_t, ST_STOP, and strdup.

Referenced by zone_str().

Variable Documentation

◆ common_year_days_in_month

const int common_year_days_in_month[]
static
Initial value:
= {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
}

Definition at line 730 of file time.c.

Referenced by gmtime_with_leapsecond(), and vtm_add_offset().

◆ common_year_yday_offset

const int common_year_yday_offset[]
static
Initial value:
= {
-1,
-1 + 31,
-1 + 31 + 28,
-1 + 31 + 28 + 31,
-1 + 31 + 28 + 31 + 30,
-1 + 31 + 28 + 31 + 30 + 31,
-1 + 31 + 28 + 31 + 30 + 31 + 30,
-1 + 31 + 28 + 31 + 30 + 31 + 30 + 31,
-1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31,
-1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
-1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
-1 + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
}

Definition at line 699 of file time.c.

Referenced by gmtimew_noleapsecond().

◆ compat_common_month_table

int compat_common_month_table[12][7]
static
Initial value:
= {
{ 2034, 2035, 2036, 2031, 2032, 2027, 2033 },
{ 2026, 2027, 2033, 2034, 2035, 2030, 2031 },
{ 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
{ 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
{ 2033, 2034, 2035, 2030, 2036, 2026, 2032 },
{ 2036, 2026, 2032, 2033, 2034, 2035, 2030 },
{ 2035, 2030, 2036, 2026, 2032, 2033, 2034 },
{ 2032, 2033, 2034, 2035, 2030, 2036, 2026 },
{ 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
{ 2034, 2035, 2030, 2036, 2026, 2032, 2033 },
{ 2026, 2032, 2033, 2034, 2035, 2030, 2036 },
{ 2030, 2036, 2026, 2032, 2033, 2034, 2035 },
}

Definition at line 1208 of file time.c.

◆ compat_leap_month_table

int compat_leap_month_table[7]
static
Initial value:
= {
2032, 2016, 2028, 2012, 2024, 2036, 2020,
}

Definition at line 1249 of file time.c.

◆ id_cmp

ID id_cmp
static

Definition at line 37 of file time.c.

Referenced by cmp(), Init_Time(), and wcmp().

◆ id_div

ID id_div
static

Definition at line 37 of file time.c.

Referenced by Init_Time().

◆ id_divmod

ID id_divmod
static

Definition at line 36 of file time.c.

Referenced by divmodv(), Init_Time(), and time_timespec().

◆ id_eq

ID id_eq
static

Definition at line 37 of file time.c.

Referenced by eq(), Init_Time(), and weq().

◆ id_mul

ID id_mul
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), and time_timespec().

◆ id_nano_den

ID id_nano_den
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), and time_mdump().

◆ id_nano_num

ID id_nano_num
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), and time_mdump().

◆ id_ne

ID id_ne
static

Definition at line 37 of file time.c.

Referenced by Init_Time().

◆ id_offset

ID id_offset
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), and time_mdump().

◆ id_quo

ID id_quo
static

Definition at line 37 of file time.c.

Referenced by Init_Time(), and quo().

◆ id_submicro

ID id_submicro
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), and time_mdump().

◆ id_zone

ID id_zone
static

Definition at line 36 of file time.c.

Referenced by Init_Time(), time_mdump(), and time_mload().

◆ known_leap_seconds_limit

time_t known_leap_seconds_limit
static

Definition at line 1050 of file time.c.

◆ leap_year_days_in_month

const int leap_year_days_in_month[]
static
Initial value:
= {
31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
}

Definition at line 733 of file time.c.

Referenced by gmtime_with_leapsecond(), and vtm_add_offset().

◆ leap_year_yday_offset

const int leap_year_yday_offset[]
static
Initial value:
= {
-1,
-1 + 31,
-1 + 31 + 29,
-1 + 31 + 29 + 31,
-1 + 31 + 29 + 31 + 30,
-1 + 31 + 29 + 31 + 30 + 31,
-1 + 31 + 29 + 31 + 30 + 31 + 30,
-1 + 31 + 29 + 31 + 30 + 31 + 30 + 31,
-1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31,
-1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30,
-1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31,
-1 + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30
}

Definition at line 714 of file time.c.

Referenced by gmtimew_noleapsecond().

◆ months

const char months[][4]
static
Initial value:
= {
"jan", "feb", "mar", "apr", "may", "jun",
"jul", "aug", "sep", "oct", "nov", "dec",
}

Definition at line 2388 of file time.c.

◆ number_of_leap_seconds_known

int number_of_leap_seconds_known
static

Definition at line 1051 of file time.c.

◆ rb_cTime

VALUE rb_cTime

◆ this_year

long this_year = 0
static

Definition at line 1049 of file time.c.

◆ time_data_type

const rb_data_type_t time_data_type
static
Initial value:
= {
"time",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static size_t time_memsize(const void *tobj)
Definition: time.c:1644
static void time_mark(void *ptr)
Definition: time.c:1633
#define RUBY_TYPED_DEFAULT_FREE
Definition: ruby.h:1141

Definition at line 1649 of file time.c.

◆ zone_table

st_table* zone_table
static

Definition at line 792 of file time.c.