Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
|
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.
RBIMPL
or rbimpl
are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will. __VA_ARGS__
is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98. 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`. |
num
. Definition at line 2943 of file time.c.
Referenced by rb_io_set_timeout(), rb_io_wait(), and rb_mutex_sleep().
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 2797 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 2789 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 2826 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`. |
num
. 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`. |
num
. 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 2803 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`. |
num
. Definition at line 2949 of file time.c.
Referenced by rb_thread_sleep().
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 5060 of file time.c.
Referenced by rb_time_utc_offset().