Ruby
3.4.0dev (2024-11-22 revision 0989400a925cd201defdca9eb28eb87200b30785)
|
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. More... | |
VALUE | rb_time_new (time_t sec, long usec) |
Creates an instance of rb_cTime with the given time and the local timezone. More... | |
VALUE | rb_time_nano_new (time_t sec, long nsec) |
Identical to rb_time_new(), except it accepts the time in nanoseconds resolution. More... | |
VALUE | rb_time_timespec_new (const struct timespec *ts, int offset) |
Creates an instance of rb_cTime, with given time and offset. More... | |
VALUE | rb_time_num_new (VALUE timev, VALUE off) |
Identical to rb_time_timespec_new(), except it takes Ruby values instead of C structs. More... | |
struct timeval | rb_time_interval (VALUE num) |
Creates a "time interval". More... | |
struct timeval | rb_time_timeval (VALUE time) |
Converts an instance of rb_cTime to a struct timeval that represents the identical point of time. More... | |
struct timespec | rb_time_timespec (VALUE time) |
Identical to rb_time_timeval(), except for return type. More... | |
struct timespec | rb_time_timespec_interval (VALUE num) |
Identical to rb_time_interval(), except for return type. More... | |
VALUE | rb_time_utc_offset (VALUE time) |
Queries the offset, in seconds between the time zone of the time and the UTC. More... | |
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 2773 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. |
VALUE rb_time_new | ( | time_t | sec, |
long | usec | ||
) |
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 . |
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 . |
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 2773 of file time.c.
Referenced by rb_thread_sleep().