Ruby: time.c File Reference

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

Macros | Typedefs | Enumerations | Functions | Variables
time.c File Reference
`#include "ruby/internal/config.h"`
`#include <errno.h>`
`#include <float.h>`
`#include <math.h>`
`#include <time.h>`
`#include <sys/types.h>`
`#include "id.h"`
`#include "internal.h"`
`#include "internal/array.h"`
`#include "internal/compar.h"`
`#include "internal/numeric.h"`
`#include "internal/rational.h"`
`#include "internal/string.h"`
`#include "internal/time.h"`
`#include "internal/variable.h"`
`#include "ruby/encoding.h"`
`#include "timev.h"`

Go to the source code of this file.

## Macros
#define | _DEFAULT_SOURCE
#define | _BSD_SOURCE
#define | id_quo idQuo
#define | id_div idDiv
#define | id_divmod idDivmod
#define | id_name idName
#define | UTC_ZONE Qundef
#define | TM_IS_TIME 1
#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 | 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 | neg(x) (subv(INT2FIX(0), (x)))
#define | mulquov(x, y, z) (((y) == (z)) ? (x) : quov(mulv((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(modv((y), INT2FIX(400))))
#define | LOCALTIME(tm, result) rb_localtime_r((tm), &(result))
#define | GMTIME(tm, result) rb_gmtime_r((tm), &(result))
#define | M28(m)
#define | M29(m)
#define | M30(m)
#define | M31(m)
#define | D28
#define | D29
#define | D30
#define | D31
#define | GMTIMEW(w, v) (gmtimew(w, v) ? (void)0 : rb_raise(rb_eArgError, "gmtime error"))
#define | TIME_TZMODE_LOCALTIME 0
#define | TIME_TZMODE_UTC 1
#define | TIME_TZMODE_FIXOFF 2
#define | TIME_TZMODE_UNINITIALIZED 3
#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)->tzmode != TIME_TZMODE_UNINITIALIZED)
#define | TZMODE_UTC_P(tobj) ((tobj)->tzmode == TIME_TZMODE_UTC)
#define | TZMODE_SET_UTC(tobj) ((tobj)->tzmode = TIME_TZMODE_UTC)
#define | TZMODE_LOCALTIME_P(tobj) ((tobj)->tzmode == TIME_TZMODE_LOCALTIME)
#define | TZMODE_SET_LOCALTIME(tobj) ((tobj)->tzmode = TIME_TZMODE_LOCALTIME)
#define | TZMODE_FIXOFF_P(tobj) ((tobj)->tzmode == TIME_TZMODE_FIXOFF)
#define | TZMODE_SET_FIXOFF(tobj, off)
#define | TZMODE_COPY(tobj1, tobj2)
#define | MAKE_TM(time, tobj)
#define | MAKE_TM_ENSURE(time, tobj, cond)
#define | EXTRACT_TIME()
#define | AREF(x) rb_struct_aref(time, ID2SYM(id_##x))
#define | AREF(x) rb_funcallv(time, id_##x, 0, 0)
#define | EXTRACT_VTM()
#define | AREF(x) rb_struct_aref(time, ID2SYM(id_##x))
#define | AREF(x) rb_funcallv(time, id_##x, 0, 0)
#define | arg_range_check(v)
#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 | wday_p(n)
#define | get_attr(attr, iffound)
#define | tm_subsec tm_zero
#define | tm_utc_offset tm_zero

## Typedefs
typedef unsigned long | uwideint_t
typedef long | wideint_t
typedef VALUE | WIDEVALUE
typedef SIGNED_VALUE | SIGNED_WIDEVALUE
typedef WIDEVALUE | wideval_t

## Enumerations
enum | { TMOPT_IN , TMOPT_MAX_ }
enum | { base_dump_size = 8 }

## Functions
void | ruby_reset_leap_second_info (void)
void | ruby_reset_timezone (void)
| PACKED_STRUCT_UNALIGNED (struct time_object { wideval_t timew;struct vtm vtm;unsigned int tzmode:3;unsigned int tm_got:1;})
void | rb_timespec_now (struct timespec *ts)
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)
struct timeval | rb_time_interval (VALUE num)
struct timeval | rb_time_timeval (VALUE time)
struct timespec | rb_time_timespec (VALUE time)
struct timespec | rb_time_timespec_interval (VALUE num)
VALUE | rb_time_utc_offset (VALUE time)
int | ruby_marshal_write_long (long x, char *buf)
long | ruby_marshal_read_long (const char **buf, long len)
VALUE | rb_time_zone_abbreviation (VALUE zone, VALUE time)
void | Init_Time (void)

## Variables
VALUE | rb_cTime
bool | ruby_tz_uptodate_p

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

## ◆ AREF [1/4]

#define AREF | ( |  | x | ) | rb_struct_aref(time, ID2SYM(id_##x))

## ◆ AREF [2/4]

#define AREF | ( |  | x | ) | rb_funcallv(time, id_##x, 0, 0)

## ◆ AREF [3/4]

#define AREF | ( |  | x | ) | rb_struct_aref(time, ID2SYM(id_##x))

## ◆ AREF [4/4]

#define AREF | ( |  | x | ) | rb_funcallv(time, id_##x, 0, 0)

## ◆ arg_range_check

#define arg_range_check | ( |  | v | ) |

Value:
(((v) < 0) ? \
rb_raise(rb_eArgError, "%s must not be negative", tstr) : \
(void)0)
rb_eArgError
VALUE rb_eArgError
Definition: error.c:1058

## ◆ D28

#define D28

Value:
1,2,3,4,5,6,7,8,9, \
10,11,12,13,14,15,16,17,18,19, \
20,21,22,23,24,25,26,27,28

Definition at line 815 of file time.c.

## ◆ D29

#define D29

Value:
1,2,3,4,5,6,7,8,9, \
10,11,12,13,14,15,16,17,18,19, \
20,21,22,23,24,25,26,27,28,29

Definition at line 819 of file time.c.

## ◆ D30

#define D30

Value:
1,2,3,4,5,6,7,8,9, \
10,11,12,13,14,15,16,17,18,19, \
20,21,22,23,24,25,26,27,28,29,30

Definition at line 823 of file time.c.

## ◆ D31

#define D31

Value:
1,2,3,4,5,6,7,8,9, \
10,11,12,13,14,15,16,17,18,19, \
20,21,22,23,24,25,26,27,28,29,30,31

Definition at line 827 of file time.c.

## ◆ DEBUG_FIND_TIME_NUMGUESS_INC

#define DEBUG_FIND_TIME_NUMGUESS_INC

Definition at line 3152 of file time.c.

## ◆ DEBUG_REPORT_GUESSRANGE

#define DEBUG_REPORT_GUESSRANGE

Definition at line 3140 of file time.c.

## ◆ DIV

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

Definition at line 64 of file time.c.

## ◆ EXTRACT_TIME

#define EXTRACT_TIME | ( |  | ) |

Value:
do { \
t = v2w(rb_Integer(AREF(to_i))); \
} while (0)
rb_Integer
VALUE rb_Integer(VALUE)
Equivalent to Kernel#Integer in Ruby.
Definition: object.c:3138
t
#define t
Definition: symbol.c:253
AREF
#define AREF(x)

## ◆ EXTRACT_VTM

#define EXTRACT_VTM | ( |  | ) |

Value:
do { \
VALUE subsecx; \
vtm->year = obj2vint(AREF(year)); \
vtm->mon = month_arg(AREF(mon)); \
vtm->mday = obj2ubits(AREF(mday), 5); \
vtm->hour = obj2ubits(AREF(hour), 5); \
vtm->min = obj2ubits(AREF(min), 6); \
vtm->sec = obj2subsecx(AREF(sec), &subsecx); \
vtm->isdst = RTEST(AREF(isdst)); \
vtm->utc_offset = Qnil; \
t = v2w(rb_Integer(AREF(to_i))); \
} while (0)
RTEST
#define RTEST
Definition: special_consts.h:42
Qnil
#define Qnil
Definition: special_consts.h:51
VALUE
unsigned long VALUE
Definition: value.h:38

## ◆ FIXWINT_P

#define FIXWINT_P | ( |  | v | ) | FIXNUM_P(v)

Definition at line 236 of file time.c.

## ◆ FIXWV2WINT

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

Definition at line 241 of file time.c.

## ◆ FIXWV_MAX

#define FIXWV_MAX FIXNUM_MAX

Definition at line 237 of file time.c.

## ◆ FIXWV_MIN

#define FIXWV_MIN FIXNUM_MIN

Definition at line 238 of file time.c.

## ◆ FIXWV_P

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

Definition at line 246 of file time.c.

## ◆ FIXWVABLE

#define FIXWVABLE | ( |  | i | ) | FIXABLE(i)

Definition at line 239 of file time.c.

## ◆ ge

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

Definition at line 96 of file time.c.

## ◆ get_attr

#define get_attr | ( |  | attr,
|  |  | iffound
| ) |  |

Value:
attr = rb_attr_delete(str, id_##attr); \
if (!NIL_P(attr)) { \
iffound; \
}
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
rb_attr_delete
VALUE rb_attr_delete(VALUE, ID)
Definition: variable.c:1287
NIL_P
#define NIL_P
Definition: special_consts.h:46

## ◆ GetNewTimeval

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

Definition at line 1740 of file time.c.

## ◆ GetTimeval

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

Definition at line 1739 of file time.c.

## ◆ GMTIME

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

Definition at line 743 of file time.c.

## ◆ GMTIMEW

#define GMTIMEW | ( |  | w,
|  |  | v
| ) |  | (gmtimew(w, v) ? (void)0 : rb_raise(rb_eArgError, "gmtime error"))

Definition at line 1300 of file time.c.

## ◆ gt

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

Definition at line 94 of file time.c.

## ◆ GUESS

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

## ◆ id_div

#define id_div idDiv

Definition at line 53 of file time.c.

## ◆ id_divmod

#define id_divmod idDivmod

Definition at line 54 of file time.c.

## ◆ id_name

#define id_name idName

Definition at line 55 of file time.c.

## ◆ id_quo

#define id_quo idQuo

Definition at line 52 of file time.c.

## ◆ IsTimeval

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

Definition at line 1742 of file time.c.

## ◆ le

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

Definition at line 95 of file time.c.

## ◆ leap_year_v_p

#define leap_year_v_p | ( |  | y | ) | leap_year_p(NUM2LONG(modv((y), INT2FIX(400))))

Definition at line 670 of file time.c.

## ◆ LOCALTIME

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

Definition at line 724 of file time.c.

## ◆ lt

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

Definition at line 93 of file time.c.

## ◆ M28

#define M28 | ( |  | m | ) |

Value:
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m)

Definition at line 784 of file time.c.

## ◆ M29

#define M29 | ( |  | m | ) |

Value:
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m)

Definition at line 788 of file time.c.

## ◆ M30

#define M30 | ( |  | m | ) |

Value:
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m)

Definition at line 792 of file time.c.

## ◆ M31

#define M31 | ( |  | m | ) |

Value:
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), \
(m),(m),(m),(m),(m),(m),(m),(m),(m),(m), (m)

Definition at line 796 of file time.c.

## ◆ MAKE_TM

#define MAKE_TM | ( |  | time,
|  |  | tobj
| ) |  |

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

Definition at line 1762 of file time.c.

## ◆ MAKE_TM_ENSURE

#define MAKE_TM_ENSURE | ( |  | time,
|  |  | tobj,
|  |  | cond
| ) |  |

Value:
do { \
MAKE_TM(time, tobj); \
if (!(cond)) { \
VALUE zone = (tobj)->vtm.zone; \
if (!NIL_P(zone)) zone_localtime(zone, (time)); \
} \
} while (0)
zone
Definition: zonetab.h:35
if
if((ID)(DISPID) nameid !=nameid)
Definition: win32ole.c:357

Definition at line 1768 of file time.c.

## ◆ MOD

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

Definition at line 65 of file time.c.

## ◆ MUL_OVERFLOW_FIXWV_P

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

Definition at line 247 of file time.c.

## ◆ mulquov

#define mulquov | ( |  | x,
|  |  | y,
|  |  | z
| ) |  | (((y) == (z)) ? (x) : quov(mulv((x),(y)),(z)))

Definition at line 181 of file time.c.

## ◆ NDIV

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

Definition at line 62 of file time.c.

## ◆ ne

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

Definition at line 92 of file time.c.

## ◆ neg

#define neg | ( |  | x | ) | (subv(INT2FIX(0), (x)))

Definition at line 151 of file time.c.

## ◆ NEGFIXWVABLE

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

Definition at line 245 of file time.c.

## ◆ NMOD

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

Definition at line 63 of file time.c.

## ◆ POSFIXWVABLE

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

Definition at line 244 of file time.c.

## ◆ strftimev

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

Definition at line 4094 of file time.c.

## ◆ TIME_INIT_P

#define TIME_INIT_P | ( |  | tobj | ) | ((tobj)->tzmode != TIME_TZMODE_UNINITIALIZED)

Definition at line 1743 of file time.c.

## ◆ TIME_TZMODE_FIXOFF

#define TIME_TZMODE_FIXOFF 2

Definition at line 1729 of file time.c.

## ◆ TIME_TZMODE_LOCALTIME

#define TIME_TZMODE_LOCALTIME 0

Definition at line 1727 of file time.c.

## ◆ TIME_TZMODE_UNINITIALIZED

#define TIME_TZMODE_UNINITIALIZED 3

Definition at line 1730 of file time.c.

## ◆ TIME_TZMODE_UTC

#define TIME_TZMODE_UTC 1

Definition at line 1728 of file time.c.

## ◆ TIMET2WV

#define TIMET2WV | ( |  | t | ) | timet2wv(t)

Definition at line 620 of file time.c.

## ◆ TM_IS_TIME

#define TM_IS_TIME 1

Definition at line 59 of file time.c.

## ◆ tm_subsec

#define tm_subsec tm_zero

Definition at line 5571 of file time.c.

## ◆ tm_utc_offset

#define tm_utc_offset tm_zero

Definition at line 5572 of file time.c.

## ◆ TZMODE_COPY

#define TZMODE_COPY | ( |  | tobj1,
|  |  | tobj2
| ) |  |

Value:
((tobj1)->tzmode = (tobj2)->tzmode, \
(tobj1)->vtm.utc_offset = (tobj2)->vtm.utc_offset, \
(tobj1)->vtm.zone = (tobj2)->vtm.zone)

Definition at line 1756 of file time.c.

## ◆ TZMODE_FIXOFF_P

#define TZMODE_FIXOFF_P | ( |  | tobj | ) | ((tobj)->tzmode == TIME_TZMODE_FIXOFF)

Definition at line 1751 of file time.c.

## ◆ TZMODE_LOCALTIME_P

#define TZMODE_LOCALTIME_P | ( |  | tobj | ) | ((tobj)->tzmode == TIME_TZMODE_LOCALTIME)

Definition at line 1748 of file time.c.

## ◆ TZMODE_SET_FIXOFF

#define TZMODE_SET_FIXOFF | ( |  | tobj,
|  |  | off
| ) |  |

Value:
((tobj)->tzmode = TIME_TZMODE_FIXOFF, \
(tobj)->vtm.utc_offset = (off))
TIME_TZMODE_FIXOFF
#define TIME_TZMODE_FIXOFF
Definition: time.c:1729

Definition at line 1752 of file time.c.

## ◆ TZMODE_SET_LOCALTIME

#define TZMODE_SET_LOCALTIME | ( |  | tobj | ) | ((tobj)->tzmode = TIME_TZMODE_LOCALTIME)

Definition at line 1749 of file time.c.

## ◆ TZMODE_SET_UTC

#define TZMODE_SET_UTC | ( |  | tobj | ) | ((tobj)->tzmode = TIME_TZMODE_UTC)

Definition at line 1746 of file time.c.

## ◆ TZMODE_UTC_P

#define TZMODE_UTC_P | ( |  | tobj | ) | ((tobj)->tzmode == TIME_TZMODE_UTC)

Definition at line 1745 of file time.c.

## ◆ UTC_ZONE

#define UTC_ZONE Qundef

Definition at line 56 of file time.c.

## ◆ UWIDEINT_MAX

#define UWIDEINT_MAX ULONG_MAX

Definition at line 233 of file time.c.

## ◆ validate_vtm_range

#define validate_vtm_range | ( |  | mem,
|  |  | b,
|  |  | e
| ) |  |

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

## ◆ VTM_ISDST_INITVAL

#define VTM_ISDST_INITVAL (3)

Definition at line 67 of file time.c.

## ◆ VTM_WDAY_INITVAL

#define VTM_WDAY_INITVAL (7)

Definition at line 66 of file time.c.

## ◆ wday_p

#define wday_p | ( |  | n | ) |

Value:
{\
return (time_wday(time) == INT2FIX(n)) ? Qtrue : Qfalse; \
}
INT2FIX
#define INT2FIX
Definition: long.h:48
Qtrue
#define Qtrue
Definition: special_consts.h:52
Qfalse
#define Qfalse
Definition: special_consts.h:50

Definition at line 4577 of file time.c.

## ◆ wge

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

Definition at line 369 of file time.c.

## ◆ wgt

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

Definition at line 367 of file time.c.

## ◆ WIDEINT_MAX

#define WIDEINT_MAX LONG_MAX

Definition at line 234 of file time.c.

## ◆ WIDEINT_MIN

#define WIDEINT_MIN LONG_MIN

Definition at line 235 of file time.c.

## ◆ WIDEVAL_GET

#define WIDEVAL_GET | ( |  | w | ) | (w)

Definition at line 260 of file time.c.

## ◆ WIDEVAL_WRAP

#define WIDEVAL_WRAP | ( |  | v | ) | (v)

Definition at line 259 of file time.c.

## ◆ WIDEVALUE_IS_WIDER

#define WIDEVALUE_IS_WIDER 0

Definition at line 232 of file time.c.

## ◆ WINT2FIXWV

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

Definition at line 240 of file time.c.

## ◆ WINT2WV

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

Definition at line 274 of file time.c.

## ◆ wle

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

Definition at line 368 of file time.c.

## ◆ wlt

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

Definition at line 366 of file time.c.

## ◆ wmulquo

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

Definition at line 425 of file time.c.

## ◆ wmulquoll

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

Definition at line 426 of file time.c.

## ◆ wne

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

Definition at line 365 of file time.c.

## ◆ WV2TIMET

#define WV2TIMET | ( |  | t | ) | wv2timet(t)

Definition at line 643 of file time.c.

## Typedef Documentation

## ◆ SIGNED_WIDEVALUE

typedef SIGNED_VALUE SIGNED_WIDEVALUE

Definition at line 231 of file time.c.

## ◆ uwideint_t

typedef unsigned long uwideint_t

Definition at line 228 of file time.c.

## ◆ wideint_t

typedef long wideint_t

Definition at line 229 of file time.c.

## ◆ wideval_t

typedef WIDEVALUE wideval_t

Definition at line 258 of file time.c.

## ◆ WIDEVALUE

typedef VALUE WIDEVALUE

Definition at line 230 of file time.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
TMOPT_IN |
TMOPT_MAX_ |

Definition at line 2726 of file time.c.

## ◆ anonymous enum

anonymous enum

Enumerator
base_dump_size |

Definition at line 5105 of file time.c.

## Function Documentation

## ◆ Init_Time()

void Init_Time | ( | void |  | ) |

Definition at line 5828 of file time.c.

References id_min, NULL, rb_cObject, rb_cTime, rb_define_alloc_func(), rb_define_class(), rb_define_method, rb_define_private_method, rb_define_singleton_method, ruby::backward::cxxanyargs::rb_define_virtual_variable(), rb_fstring_lit, rb_gc_register_mark_object(), rb_include_module(), rb_mComparable, rb_singleton_class(), and rb_time_utc_offset().

## ◆ PACKED_STRUCT_UNALIGNED()

PACKED_STRUCT_UNALIGNED | ( | struct time_object { wideval_t timew;struct vtm vtm;unsigned int tzmode:3;unsigned int tm_got:1;} |  | ) |

## ◆ rb_time_interval()

struct timeval rb_time_interval | ( | VALUE | num | ) |

Definition at line 2684 of file time.c.

References num, and TRUE.

Referenced by rb_io_wait(), and rb_mutex_sleep().

## ◆ rb_time_nano_new()

VALUE rb_time_nano_new | ( | time_t | sec,
|  | long | nsec
| ) |  |

Definition at line 2534 of file time.c.

References rb_cTime.

## ◆ rb_time_new()

VALUE rb_time_new | ( | time_t | sec,
|  | long | usec
| ) |  |

Definition at line 2507 of file time.c.

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

## ◆ rb_time_num_new()

VALUE rb_time_num_new | ( | VALUE | timev,
|  | VALUE | off
| ) |  |

Definition at line 2568 of file time.c.

References NIL_P, rb_cTime, and UTC_ZONE.

## ◆ rb_time_timespec()

struct timespec rb_time_timespec | ( | VALUE | time | ) |

Definition at line 2707 of file time.c.

References FALSE, GetTimeval, IsTimeval, and t.

## ◆ rb_time_timespec_interval()

struct timespec rb_time_timespec_interval | ( | VALUE | num | ) |

Definition at line 2721 of file time.c.

References num, and TRUE.

## ◆ 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 2545 of file time.c.

References GetTimeval, INT2FIX, rb_cTime, rb_eArgError, rb_raise(), timespec::tv_nsec, timespec::tv_sec, TZMODE_SET_FIXOFF, and TZMODE_SET_UTC.

## ◆ rb_time_timeval()

struct timeval rb_time_timeval | ( | VALUE | time | ) |

Definition at line 2690 of file time.c.

References FALSE, GetTimeval, IsTimeval, t, timespec::tv_nsec, timespec::tv_sec, TYPEOF_TIMEVAL_TV_SEC, and TYPEOF_TIMEVAL_TV_USEC.

Referenced by rb_thread_sleep().

## ◆ rb_time_utc_offset()

VALUE rb_time_utc_offset | ( | VALUE | time | ) |

Definition at line 4801 of file time.c.

References GetTimeval, INT2FIX, MAKE_TM, and TZMODE_UTC_P.

Referenced by Init_Time().

## ◆ rb_time_zone_abbreviation()

VALUE rb_time_zone_abbreviation | ( | VALUE | zone,
|  | VALUE | time
| ) |  |

Definition at line 5664 of file time.c.

References NIL_P, Qnil, Qundef, rb_check_funcall(), rb_check_funcall_default(), rb_check_string_type(), rb_fstring_lit, rb_funcallv, rb_intern(), and rb_obj_as_string().

## ◆ rb_timespec_now()

void rb_timespec_now | ( | struct timespec * | ts | ) |

Definition at line 1889 of file time.c.

References clock_gettime(), CLOCK_REALTIME, gettimeofday(), rb_sys_fail(), timespec::tv_nsec, timeval::tv_sec, timespec::tv_sec, and timeval::tv_usec.

## ◆ ruby_marshal_read_long()

long ruby_marshal_read_long | ( | const char ** | buf,
|  | long | len
| ) |  |

Definition at line 1299 of file marshal.c.

## ◆ ruby_marshal_write_long()

int ruby_marshal_write_long | ( | long | x,
|  | char * | buf
| ) |  |

Definition at line 320 of file marshal.c.

## ◆ ruby_reset_leap_second_info()

void ruby_reset_leap_second_info | ( | void |  | ) |

Definition at line 1201 of file time.c.

Referenced by ruby_reset_timezone().

## ◆ ruby_reset_timezone()

void ruby_reset_timezone | ( | void |  | ) |

Definition at line 678 of file time.c.

References ruby_reset_leap_second_info(), and ruby_tz_uptodate_p.

## Variable Documentation

## ◆ rb_cTime

VALUE rb_cTime

Definition at line 645 of file time.c.

Referenced by asn1time_to_time(), Init_date_core(), Init_Time(), ole_val2variant(), rb_time_nano_new(), rb_time_new(), rb_time_num_new(), and rb_time_timespec_new().

## ◆ ruby_tz_uptodate_p

bool ruby_tz_uptodate_p

Definition at line 674 of file time.c.

Referenced by ruby_reset_timezone().