Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

time.c File Reference

#include "ruby.h"
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

Go to the source code of this file.

Data Structures

struct  time_object

Defines

#define GetTimeval(obj, tobj)   Data_Get_Struct(obj, struct time_object, tobj)
#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 SMALLBUF   100

Typedefs

typedef unsigned long unsigned_time_t

Functions

void time_free (void *)
VALUE time_s_alloc (VALUE)
void time_modify (VALUE time)
VALUE time_init (VALUE time)
void time_overflow_p (time_t *secp, time_t *usecp)
VALUE time_new_internal (VALUE klass, time_t sec, time_t usec)
VALUE rb_time_new (time_t sec, time_t usec)
timeval time_timeval (VALUE time, int interval)
timeval rb_time_interval (VALUE time)
timeval rb_time_timeval (VALUE time)
VALUE time_s_at (int argc, VALUE *argv, VALUE klass)
long obj2long (VALUE obj)
void time_arg (int argc, VALUE *argv, struct tm *tm, time_t *usec)
VALUE time_gmtime (VALUE)
VALUE time_localtime (VALUE)
VALUE time_get_tm (VALUE, int)
int leap_year_p (long y)
time_t timegm_noleapsecond (struct tm *tm)
int tmcmp (struct tm *a, struct tm *b)
time_t search_time_t (struct tm *tptr, int utc_p)
time_t make_time_t (struct tm *tptr, int utc_p)
VALUE time_utc_or_local (int argc, VALUE *argv, int utc_p, VALUE klass)
VALUE time_s_mkutc (int argc, VALUE *argv, VALUE klass)
VALUE time_s_mktime (int argc, VALUE *argv, VALUE klass)
VALUE time_to_i (VALUE time)
VALUE time_to_f (VALUE time)
VALUE time_usec (VALUE time)
VALUE time_cmp (VALUE time1, VALUE time2)
VALUE time_eql (VALUE time1, VALUE time2)
VALUE time_utc_p (VALUE time)
VALUE time_hash (VALUE time)
VALUE time_init_copy (VALUE copy, VALUE time)
VALUE time_dup (VALUE time)
VALUE time_getlocaltime (VALUE time)
VALUE time_getgmtime (VALUE time)
VALUE time_asctime (VALUE time)
VALUE time_to_s (VALUE time)
VALUE time_add (struct time_object *tobj, VALUE offset, int sign)
VALUE time_plus (VALUE time1, VALUE time2)
VALUE time_minus (VALUE time1, VALUE time2)
VALUE time_succ (VALUE time)
VALUE time_sec (VALUE time)
VALUE time_min (VALUE time)
VALUE time_hour (VALUE time)
VALUE time_mday (VALUE time)
VALUE time_mon (VALUE time)
VALUE time_year (VALUE time)
VALUE time_wday (VALUE time)
VALUE time_yday (VALUE time)
VALUE time_isdst (VALUE time)
VALUE time_zone (VALUE time)
VALUE time_utc_offset (VALUE time)
VALUE time_to_a (VALUE time)
int rb_strftime (char **buf, const char *format, struct tm *time)
VALUE time_strftime (VALUE time, VALUE format)
VALUE time_s_times (VALUE obj)
VALUE time_mdump (VALUE time)
VALUE time_dump (int argc, VALUE *argv, VALUE time)
VALUE time_mload (VALUE time, VALUE str)
VALUE time_load (VALUE klass, VALUE str)
void Init_Time ()

Variables

VALUE rb_cTime
char * months [12]


Define Documentation

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

Definition at line 410 of file time.c.

Referenced by timegm_noleapsecond().

#define GetTimeval obj,
tobj   )     Data_Get_Struct(obj, struct time_object, tobj)
 

Definition at line 32 of file time.c.

Referenced by time_add(), time_asctime(), time_cmp(), time_eql(), time_gmtime(), time_hash(), time_hour(), time_init(), time_init_copy(), time_isdst(), time_localtime(), time_mday(), time_mdump(), time_min(), time_minus(), time_mload(), time_mon(), time_new_internal(), time_plus(), time_s_at(), time_sec(), time_strftime(), time_succ(), time_to_a(), time_to_f(), time_to_i(), time_to_s(), time_usec(), time_utc_offset(), time_utc_p(), time_wday(), time_yday(), time_year(), and time_zone().

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

Definition at line 109 of file time.c.

Referenced by time_overflow_p().

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

Definition at line 110 of file time.c.

Referenced by time_overflow_p().

#define SMALLBUF   100
 

Definition at line 1743 of file time.c.


Typedef Documentation

typedef unsigned long unsigned_time_t
 

Definition at line 1259 of file time.c.

Referenced by time_add().


Function Documentation

void Init_Time void   ) 
 

Definition at line 2044 of file time.c.

References rb_class_new_instance(), rb_cObject, rb_cTime, rb_define_alloc_func(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_include_module(), rb_mComparable, time_asctime(), time_cmp(), time_dump(), time_eql(), time_getgmtime(), time_getlocaltime(), time_gmtime(), time_hash(), time_hour(), time_init(), time_init_copy(), time_isdst(), time_load(), time_localtime(), time_mday(), time_mdump(), time_min(), time_minus(), time_mload(), time_mon(), time_plus(), time_s_alloc(), time_s_at(), time_s_mktime(), time_s_mkutc(), time_s_times(), time_sec(), time_strftime(), time_succ(), time_to_a(), time_to_f(), time_to_i(), time_to_s(), time_usec(), time_utc_offset(), time_utc_p(), time_wday(), time_yday(), time_year(), and time_zone().

Referenced by rb_call_inits().

int leap_year_p long  y  )  [static]
 

Definition at line 404 of file time.c.

Referenced by timegm_noleapsecond().

time_t make_time_t struct tm *  tptr,
int  utc_p
[static]
 

Definition at line 744 of file time.c.

References search_time_t(), and time_t.

Referenced by time_mload(), and time_utc_or_local().

long obj2long VALUE  obj  )  [static]
 

Definition at line 285 of file time.c.

References NUM2LONG, Qfalse, rb_str_to_inum(), T_STRING, TYPE, and VALUE.

Referenced by time_arg().

int rb_strftime char **  buf,
const char *  format,
struct tm *  time
[static]
 

Definition at line 1745 of file time.c.

References free, SMALLBUF, strftime(), and xmalloc.

Referenced by time_strftime().

struct timeval rb_time_interval VALUE  time  ) 
 

Definition at line 216 of file time.c.

References rb_time_interval(), and VALUE.

Referenced by rb_f_select(), and rb_f_sleep().

VALUE rb_time_new time_t  sec,
time_t  usec
 

Definition at line 159 of file time.c.

References rb_cTime, time_new_internal(), and time_t.

Referenced by rb_f_test(), rb_file_atime(), rb_file_ctime(), rb_file_mtime(), rb_file_s_atime(), rb_file_s_ctime(), rb_file_s_mtime(), rb_stat_atime(), rb_stat_ctime(), rb_stat_mtime(), time_add(), and time_succ().

struct timeval rb_time_timeval VALUE  time  ) 
 

Definition at line 223 of file time.c.

References rb_time_timeval(), T_DATA, time_free(), and VALUE.

time_t search_time_t struct tm *  tptr,
int  utc_p
[static]
 

Definition at line 490 of file time.c.

References NULL, rb_eArgError, rb_raise(), time_t, timegm_noleapsecond(), and tmcmp().

Referenced by make_time_t().

VALUE time_add struct time_object tobj,
VALUE  offset,
int  sign
[static]
 

Definition at line 1269 of file time.c.

References GetTimeval, NUM2DBL, rb_eRangeError, rb_raise(), rb_time_new(), time_t, unsigned_time_t, and VALUE.

Referenced by time_minus(), and time_plus().

void time_arg int  argc,
VALUE argv,
struct tm *  tm,
time_t *  usec
[static]
 

Definition at line 296 of file time.c.

References MEMZERO, months, NIL_P, obj2long(), Qnil, rb_check_string_type(), rb_eArgError, rb_raise(), rb_scan_args(), rb_warning(), RSTRING, RTEST, strcasecmp(), time_t, and VALUE.

Referenced by time_utc_or_local().

VALUE time_asctime VALUE  time  )  [static]
 

Definition at line 1208 of file time.c.

References GetTimeval, rb_str_new2(), time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_cmp VALUE  time1,
VALUE  time2
[static]
 

Definition at line 940 of file time.c.

References GetTimeval, INT2FIX, Qnil, RDATA, T_DATA, time_free(), TYPE, and VALUE.

Referenced by Init_Time().

VALUE time_dump int  argc,
VALUE argv,
VALUE  time
[static]
 

Definition at line 1931 of file time.c.

References FL_EXIVAR, FL_SET, FL_TEST, rb_copy_generic_ivar(), rb_scan_args(), time_mdump(), and VALUE.

Referenced by Init_Time().

VALUE time_dup VALUE  time  )  [static]
 

Definition at line 1054 of file time.c.

References rb_cTime, time_init_copy(), time_s_alloc(), and VALUE.

Referenced by time_getgmtime(), and time_getlocaltime().

VALUE time_eql VALUE  time1,
VALUE  time2
[static]
 

Definition at line 970 of file time.c.

References GetTimeval, Qfalse, Qtrue, RDATA, T_DATA, time_free(), TYPE, and VALUE.

Referenced by Init_Time().

void time_free void *   )  [static]
 

Definition at line 38 of file time.c.

References free.

Referenced by rb_time_timeval(), time_cmp(), time_eql(), time_init_copy(), time_minus(), time_plus(), time_s_alloc(), and time_s_at().

VALUE time_get_tm VALUE  ,
int 
[static]
 

Definition at line 1189 of file time.c.

References time_gmtime(), time_localtime(), and VALUE.

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

VALUE time_getgmtime VALUE  time  )  [static]
 

Definition at line 1182 of file time.c.

References time_dup(), time_gmtime(), and VALUE.

Referenced by Init_Time().

VALUE time_getlocaltime VALUE  time  )  [static]
 

Definition at line 1160 of file time.c.

References time_dup(), time_localtime(), and VALUE.

Referenced by Init_Time().

VALUE time_gmtime VALUE   )  [static]
 

Definition at line 1120 of file time.c.

References GetTimeval, rb_eArgError, rb_raise(), time_modify(), time_t, and VALUE.

Referenced by Init_Time(), time_get_tm(), time_getgmtime(), and time_utc_or_local().

VALUE time_hash VALUE  time  )  [static]
 

Definition at line 1023 of file time.c.

References GetTimeval, LONG2FIX, and VALUE.

Referenced by Init_Time().

VALUE time_hour VALUE  time  )  [static]
 

Definition at line 1448 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_init VALUE  time  )  [static]
 

Definition at line 92 of file time.c.

References GetTimeval, rb_sys_fail(), time_modify(), and VALUE.

Referenced by Init_Time().

VALUE time_init_copy VALUE  copy,
VALUE  time
[static]
 

Definition at line 1036 of file time.c.

References GetTimeval, MEMCPY, rb_eTypeError, rb_raise(), RDATA, T_DATA, time_free(), time_modify(), TYPE, and VALUE.

Referenced by Init_Time(), and time_dup().

VALUE time_isdst VALUE  time  )  [static]
 

Definition at line 1595 of file time.c.

References GetTimeval, Qfalse, Qtrue, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_load VALUE  klass,
VALUE  str
[static]
 

Definition at line 2012 of file time.c.

References FL_EXIVAR, FL_SET, FL_TEST, rb_copy_generic_ivar(), time_mload(), time_s_alloc(), and VALUE.

Referenced by Init_Time().

VALUE time_localtime VALUE   )  [static]
 

Definition at line 1076 of file time.c.

References GetTimeval, rb_eArgError, rb_raise(), time_modify(), time_t, and VALUE.

Referenced by Init_Time(), time_get_tm(), time_getlocaltime(), and time_utc_or_local().

VALUE time_mday VALUE  time  )  [static]
 

Definition at line 1473 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_mdump VALUE  time  )  [static]
 

Definition at line 1884 of file time.c.

References GetTimeval, rb_eArgError, rb_raise(), rb_str_new(), RSHIFT, time_t, and VALUE.

Referenced by Init_Time(), and time_dump().

VALUE time_min VALUE  time  )  [static]
 

Definition at line 1425 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_minus VALUE  time1,
VALUE  time2
[static]
 

Definition at line 1351 of file time.c.

References GetTimeval, rb_float_new(), RDATA, T_DATA, time_add(), time_free(), TYPE, and VALUE.

Referenced by Init_Time().

VALUE time_mload VALUE  time,
VALUE  str
[static]
 

Definition at line 1953 of file time.c.

References GetTimeval, make_time_t(), Qtrue, rb_eTypeError, rb_raise(), RSTRING, StringValue, time_modify(), time_overflow_p(), time_t, and VALUE.

Referenced by Init_Time(), and time_load().

void time_modify VALUE  time  )  [static]
 

Definition at line 61 of file time.c.

References OBJ_TAINTED, rb_check_frozen(), rb_eSecurityError, rb_raise(), rb_safe_level, and VALUE.

Referenced by time_gmtime(), time_init(), time_init_copy(), time_localtime(), and time_mload().

VALUE time_mon VALUE  time  )  [static]
 

Definition at line 1498 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_new_internal VALUE  klass,
time_t  sec,
time_t  usec
[static]
 

Definition at line 143 of file time.c.

References GetTimeval, time_overflow_p(), time_s_alloc(), time_t, and VALUE.

Referenced by rb_time_new(), time_s_at(), and time_utc_or_local().

void time_overflow_p time_t *  secp,
time_t *  usecp
[static]
 

Definition at line 113 of file time.c.

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

Referenced by time_mload(), and time_new_internal().

VALUE time_plus VALUE  time1,
VALUE  time2
[static]
 

Definition at line 1323 of file time.c.

References GetTimeval, rb_eTypeError, rb_raise(), RDATA, T_DATA, time_add(), time_free(), TYPE, and VALUE.

Referenced by Init_Time().

VALUE time_s_alloc VALUE   )  [static]
 

Definition at line 46 of file time.c.

References Data_Make_Struct, time_free(), and VALUE.

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

VALUE time_s_at int  argc,
VALUE argv,
VALUE  klass
[static]
 

Definition at line 253 of file time.c.

References GetTimeval, NUM2LONG, rb_scan_args(), rb_time_timeval(), RDATA, T_DATA, time_free(), time_new_internal(), timeval::tv_sec, timeval::tv_usec, TYPE, and VALUE.

Referenced by Init_Time().

VALUE time_s_mktime int  argc,
VALUE argv,
VALUE  klass
[static]
 

Definition at line 848 of file time.c.

References Qfalse, time_utc_or_local(), and VALUE.

Referenced by Init_Time().

VALUE time_s_mkutc int  argc,
VALUE argv,
VALUE  klass
[static]
 

Definition at line 826 of file time.c.

References Qtrue, time_utc_or_local(), and VALUE.

Referenced by Init_Time().

VALUE time_s_times VALUE  obj  )  [static]
 

Definition at line 1872 of file time.c.

References rb_proc_times(), rb_warn(), and VALUE.

Referenced by Init_Time().

VALUE time_sec VALUE  time  )  [static]
 

Definition at line 1402 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_strftime VALUE  time,
VALUE  format
[static]
 

Definition at line 1818 of file time.c.

References free, GetTimeval, rb_str_cat(), rb_str_new(), rb_str_new4(), rb_strftime(), rb_warning(), RSTRING, SMALLBUF, StringValue, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_succ VALUE  time  )  [static]
 

Definition at line 1379 of file time.c.

References GetTimeval, rb_time_new(), and VALUE.

Referenced by Init_Time().

struct timeval time_timeval VALUE  time,
int  interval
[static]
 

Definition at line 166 of file time.c.

References T_FIXNUM, T_FLOAT, time_t, time_timeval(), and VALUE.

Referenced by time_timeval().

VALUE time_to_a VALUE  time  )  [static]
 

Definition at line 1721 of file time.c.

References GetTimeval, INT2FIX, LONG2NUM, rb_ary_new3(), time_get_tm(), time_zone(), and VALUE.

Referenced by Init_Time().

VALUE time_to_f VALUE  time  )  [static]
 

Definition at line 892 of file time.c.

References GetTimeval, rb_float_new(), and VALUE.

Referenced by Init_Time().

VALUE time_to_i VALUE  time  )  [static]
 

Definition at line 870 of file time.c.

References GetTimeval, LONG2NUM, and VALUE.

Referenced by Init_Time().

VALUE time_to_s VALUE  time  )  [static]
 

Definition at line 1238 of file time.c.

References GetTimeval, rb_str_new(), strftime(), time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_usec VALUE  time  )  [static]
 

Definition at line 914 of file time.c.

References GetTimeval, LONG2NUM, and VALUE.

Referenced by Init_Time().

VALUE time_utc_offset VALUE  time  )  [static]
 

Definition at line 1664 of file time.c.

References GetTimeval, INT2FIX, INT2NUM, LONG2FIX, rb_eArgError, rb_raise(), time_get_tm(), time_t, timeval::tv_sec, and VALUE.

Referenced by Init_Time().

VALUE time_utc_or_local int  argc,
VALUE argv,
int  utc_p,
VALUE  klass
[static]
 

Definition at line 788 of file time.c.

References make_time_t(), time_arg(), time_gmtime(), time_localtime(), time_new_internal(), time_t, and VALUE.

Referenced by time_s_mktime(), and time_s_mkutc().

VALUE time_utc_p VALUE  time  )  [static]
 

Definition at line 1005 of file time.c.

References GetTimeval, Qfalse, Qtrue, and VALUE.

Referenced by Init_Time().

VALUE time_wday VALUE  time  )  [static]
 

Definition at line 1545 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_yday VALUE  time  )  [static]
 

Definition at line 1568 of file time.c.

References GetTimeval, INT2FIX, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_year VALUE  time  )  [static]
 

Definition at line 1521 of file time.c.

References GetTimeval, LONG2NUM, time_get_tm(), and VALUE.

Referenced by Init_Time().

VALUE time_zone VALUE  time  )  [static]
 

Definition at line 1621 of file time.c.

References GetTimeval, rb_str_new(), rb_str_new2(), strftime(), time_get_tm(), and VALUE.

Referenced by Init_Time(), and time_to_a().

time_t timegm_noleapsecond struct tm *  tm  )  [static]
 

Definition at line 413 of file time.c.

References DIV, leap_year_p(), and time_t.

Referenced by search_time_t().

int tmcmp struct tm *  a,
struct tm *  b
[static]
 

Definition at line 469 of file time.c.

Referenced by search_time_t().


Variable Documentation