Name

Time — Time class

Synopsis

Time is an object corresponding to a certain time. Internally, it’s stored as a number of seconds since the epoch, 00:00:00, January 1, 1970 UTC. Time class can handle both a system’s local time and UTC at the same time, but no other time zones can be handled.

Included Module

Comparable

Class Methods

Time::at(time[, usec=0])

Creates a Time object. time may be a Time object or an integer representing the number of seconds elapsed since the epoch, 00:00:00, January 1, 1970 UTC.

Time::gm(year[,month=1[,day=1[,hour=0[,min=0[,sec=0[,usec=0]]]]])

see Time::utc(year[,month=1[,day=1[,hour=0[,min=0[,sec=0 [,usec=]]]]]])

Time::local(year[,month=1[,day=1[,hour=0[,min=0[,sec=0 [,usec=0]]]]]])
Time::mktime(year[,month=1[,day=1[,hour=0[,min=0[,sec=0 [,usec=0]]]]]])

Creates a Time object interpreted in the local time zone.

Time::new
Time::now

Creates a Time object expressing the current system time.

Time::times

Returns a Tms structure containing user and system CPU times retrieved by the times system call. Here are the Tms structure members:

utime

User CPU time

stime

System CPU time

cutime

CPU time elapsed for user child processes

cstime

CPU time elapsed for system child processes

Time::utc(year[,month=1[,day=1[,hour=0[,min=0[,sec=0 [,usec=0]]]]]])
Time::gm(year[,month=1[,day=1[,hour=0[,min=0[,sec=0[,usec=0]]]]])

Creates a Time object interpreted as UTC (Coordinated Universal Time, formally known as GMT).

Instance Methods

t + n

Returns a Time object with n number of seconds added.

Get Ruby in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.