Returns the commercial-date weekday index for self
(see Date.commercial
); 1 is Monday:
Date.new(2001, 2, 3).cwday # => 6
Returns true
if self
is a Sunday, false
otherwise.
Returns true
if self
is a Monday, false
otherwise.
Returns true
if self
is a Tuesday, false
otherwise.
Returns true
if self
is a Wednesday, false
otherwise.
Returns true
if self
is a Thursday, false
otherwise.
Returns true
if self
is a Friday, false
otherwise.
Returns the Julian start date for calendar reform; if not an infinity, the returned value is suitable for passing to Date#jd
:
d = Date.new(2001, 2, 3, Date::ITALY) s = d.start # => 2299161.0 Date.jd(s).to_s # => "1582-10-15" d = Date.new(2001, 2, 3, Date::ENGLAND) s = d.start # => 2361222.0 Date.jd(s).to_s # => "1752-09-14" Date.new(2001, 2, 3, Date::GREGORIAN).start # => -Infinity Date.new(2001, 2, 3, Date::JULIAN).start # => Infinity
See argument start.
Equivalent to Date#new_start
with argument Date::ITALY
.
Returns the integer day of the month for self
, in range (1..31):
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.mday # => 2
Returns the integer day of the month for self
, in range (1..31):
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.mday # => 2
Returns the integer day of the week for self
, in range (0..6), with Sunday as zero.
t = Time.new(2000, 1, 2, 3, 4, 5, 6) # => 2000-01-02 03:04:05 +000006 t.wday # => 0 t.sunday? # => true
Returns the integer day of the year of self
, in range (1..366).
Time.new(2000, 1, 1).yday # => 1 Time.new(2000, 12, 31).yday # => 366
Returns true
if self
represents a Sunday, false
otherwise:
t = Time.utc(2000, 1, 2) # => 2000-01-02 00:00:00 UTC t.sunday? # => true
Related: Time#monday?
, Time#tuesday?
, Time#wednesday?
.
Returns true
if self
represents a Monday, false
otherwise:
t = Time.utc(2000, 1, 3) # => 2000-01-03 00:00:00 UTC t.monday? # => true
Related: Time#tuesday?
, Time#wednesday?
, Time#thursday?
.
Returns true
if self
represents a Tuesday, false
otherwise:
t = Time.utc(2000, 1, 4) # => 2000-01-04 00:00:00 UTC t.tuesday? # => true
Related: Time#wednesday?
, Time#thursday?
, Time#friday?
.
Returns true
if self
represents a Wednesday, false
otherwise:
t = Time.utc(2000, 1, 5) # => 2000-01-05 00:00:00 UTC t.wednesday? # => true
Related: Time#thursday?
, Time#friday?
, Time#saturday?
.
Returns true
if self
represents a Thursday, false
otherwise:
t = Time.utc(2000, 1, 6) # => 2000-01-06 00:00:00 UTC t.thursday? # => true
Related: Time#friday?
, Time#saturday?
, Time#sunday?
.
Returns true
if self
represents a Friday, false
otherwise:
t = Time.utc(2000, 1, 7) # => 2000-01-07 00:00:00 UTC t.friday? # => true
Related: Time#saturday?
, Time#sunday?
, Time#monday?
.
Returns a new Time
object based on the given arguments.
Required argument time
may be either of:
A Time
object, whose value is the basis for the returned time; also influenced by optional keyword argument in:
(see below).
A numeric number of Epoch seconds for the returned time.
Examples:
t = Time.new(2000, 12, 31, 23, 59, 59) # => 2000-12-31 23:59:59 -0600 secs = t.to_i # => 978328799 Time.at(secs) # => 2000-12-31 23:59:59 -0600 Time.at(secs + 0.5) # => 2000-12-31 23:59:59.5 -0600 Time.at(1000000000) # => 2001-09-08 20:46:40 -0500 Time.at(0) # => 1969-12-31 18:00:00 -0600 Time.at(-1000000000) # => 1938-04-24 17:13:20 -0500
Optional numeric argument subsec
and optional symbol argument units
work together to specify subseconds for the returned time; argument units
specifies the units for subsec
:
:millisecond
: subsec
in milliseconds:
Time.at(secs, 0, :millisecond) # => 2000-12-31 23:59:59 -0600 Time.at(secs, 500, :millisecond) # => 2000-12-31 23:59:59.5 -0600 Time.at(secs, 1000, :millisecond) # => 2001-01-01 00:00:00 -0600 Time.at(secs, -1000, :millisecond) # => 2000-12-31 23:59:58 -0600
:microsecond
or :usec
: subsec
in microseconds:
Time.at(secs, 0, :microsecond) # => 2000-12-31 23:59:59 -0600 Time.at(secs, 500000, :microsecond) # => 2000-12-31 23:59:59.5 -0600 Time.at(secs, 1000000, :microsecond) # => 2001-01-01 00:00:00 -0600 Time.at(secs, -1000000, :microsecond) # => 2000-12-31 23:59:58 -0600
:nanosecond
or :nsec
: subsec
in nanoseconds:
Time.at(secs, 0, :nanosecond) # => 2000-12-31 23:59:59 -0600 Time.at(secs, 500000000, :nanosecond) # => 2000-12-31 23:59:59.5 -0600 Time.at(secs, 1000000000, :nanosecond) # => 2001-01-01 00:00:00 -0600 Time.at(secs, -1000000000, :nanosecond) # => 2000-12-31 23:59:58 -0600
Optional keyword argument in: zone
specifies the timezone for the returned time:
Time.at(secs, in: '+12:00') # => 2001-01-01 17:59:59 +1200 Time.at(secs, in: '-12:00') # => 2000-12-31 17:59:59 -1200
For the forms of argument zone
, see Timezone Specifiers.
Returns pathname configuration variable using fpathconf().
name should be a constant under Etc
which begins with PC_
.
The return value is an integer or nil. nil means indefinite limit. (fpathconf() returns -1 but errno is not set.)
require 'etc' IO.pipe {|r, w| p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096 }
Returns true
if the stream is associated with a terminal device (tty), false
otherwise:
f = File.new('t.txt').isatty #=> false f.close f = File.new('/dev/tty').isatty #=> true f.close