Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
Public APIs related to rb_cTime. More...
#include "ruby/internal/config.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
Go to the source code of this file.
Functions | |
void | rb_timespec_now (struct timespec *ts) |
Fills the current time into the given struct. | |
VALUE | rb_time_new (time_t sec, long usec) |
Creates an instance of rb_cTime with the given time and the local timezone. | |
VALUE | rb_time_nano_new (time_t sec, long nsec) |
Identical to rb_time_new(), except it accepts the time in nanoseconds resolution. | |
VALUE | rb_time_timespec_new (const struct timespec *ts, int offset) |
Creates an instance of rb_cTime, with given time and offset. | |
VALUE | rb_time_num_new (VALUE timev, VALUE off) |
Identical to rb_time_timespec_new(), except it takes Ruby values instead of C structs. | |
struct timeval | rb_time_interval (VALUE num) |
Creates a "time interval". | |
struct timeval | rb_time_timeval (VALUE time) |
Converts an instance of rb_cTime to a struct timeval that represents the identical point of time. | |
struct timespec | rb_time_timespec (VALUE time) |
Identical to rb_time_timeval(), except for return type. | |
struct timespec | rb_time_timespec_interval (VALUE num) |
Identical to rb_time_interval(), except for return type. | |
VALUE | rb_time_utc_offset (VALUE time) |
Queries the offset, in seconds between the time zone of the time and the UTC. |
Public APIs related to rb_cTime.
Definition in file time.h.
Creates a "time interval".
This basically converts an instance of rb_cNumeric into a struct timeval, but for instance negative time interval must not exist.
[in] | num | An instance of rb_cNumeric. |
rb_eArgError | `num` is negative. |
rb_eRangeError | `num` is out of range of `timeval::tv_sec`. |
Definition at line 2935 of file time.c.
Referenced by rb_io_set_timeout(), rb_io_wait(), rb_mutex_sleep(), and rb_time_interval().
VALUE rb_time_nano_new | ( | time_t | sec, |
long | nsec ) |
Identical to rb_time_new(), except it accepts the time in nanoseconds resolution.
[in] | sec | Seconds since the UNIX epoch. |
[in] | nsec | Subsecond part, in nanoseconds resolution. |
rb_eRangeError | Cannot express the time. |
Definition at line 2789 of file time.c.
Referenced by rb_time_nano_new().
VALUE rb_time_new | ( | time_t | sec, |
long | usec ) |
Creates an instance of rb_cTime with the given time and the local timezone.
[in] | sec | Seconds since the UNIX epoch. |
[in] | usec | Subsecond part, in microseconds resolution. |
rb_eRangeError | Cannot express the time. |
Definition at line 2781 of file time.c.
Referenced by rb_time_new().
Identical to rb_time_timespec_new(), except it takes Ruby values instead of C structs.
[in] | timev | Something numeric. Currently Integers, Rationals, and Floats are accepted. |
[in] | off | Offset specifier. As of 2.7 this argument is heavily extended to take following kinds of objects:
|
rb_eArgError | Malformed `off`. |
Definition at line 2818 of file time.c.
Referenced by rb_time_num_new().
Identical to rb_time_timeval(), except for return type.
[in] | time | Instance of either rb_cTime or rb_cNumeric. |
rb_eRangeError | `time` is out of range of `timeval::tv_sec`. |
Definition at line 2958 of file time.c.
Referenced by rb_time_timespec().
Identical to rb_time_interval(), except for return type.
[in] | num | An instance of rb_cNumeric. |
rb_eArgError | `num` is negative. |
rb_eRangeError | `num` is out of range of `timespec::tv_sec`. |
Definition at line 2972 of file time.c.
Referenced by rb_time_timespec_interval().
Creates an instance of rb_cTime, with given time and offset.
[in] | ts | Time specifier. |
[in] | offset | Offset specifier, can take following values:
|
rb_eArgError | Malformed `offset`. |
Definition at line 2795 of file time.c.
Referenced by rb_time_timespec_new().
Converts an instance of rb_cTime to a struct timeval that represents the identical point of time.
It can also take something numeric; would consider it as a UNIX time then.
[in] | time | Instance of either rb_cTime or rb_cNumeric. |
rb_eRangeError | `time` is out of range of `timeval::tv_sec`. |
Definition at line 2941 of file time.c.
Referenced by rb_thread_sleep(), and rb_time_timeval().
Queries the offset, in seconds between the time zone of the time and the UTC.
[in] | time | An instance of rb_cTime. |
Definition at line 5063 of file time.c.
Referenced by rb_time_utc_offset().