Results for: "Data"

Returns rat truncated (toward zero) to a precision of ndigits decimal digits (default: 0).

When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros.

Returns a rational when ndigits is positive, otherwise returns an integer.

Rational(3).truncate      #=> 3
Rational(2, 3).truncate   #=> 0
Rational(-3, 2).truncate  #=> -1

  #    decimal      -  1  2  3 . 4  5  6
  #                   ^  ^  ^  ^   ^  ^
  #   precision      -3 -2 -1  0  +1 +2

Rational('-123.456').truncate(+1).to_f  #=> -123.4
Rational('-123.456').truncate(-1)       #=> -120

Returns a simpler approximation of the value if the optional argument eps is given (rat-|eps| <= result <= rat+|eps|), self otherwise.

r = Rational(5033165, 16777216)
r.rationalize                    #=> (5033165/16777216)
r.rationalize(Rational('0.01'))  #=> (3/10)
r.rationalize(Rational('0.1'))   #=> (1/3)

Creates a date object denoting the present day.

Date.today   #=> #<Date: 2011-06-11 ...>

Returns the day of the year (1-366).

Date.new(2001,2,3).yday           #=> 34

Returns the day of the month (1-31).

Date.new(2001,2,3).mday           #=> 3

Returns the day of the month (1-31).

Date.new(2001,2,3).mday           #=> 3

Returns the day of calendar week (1-7, Monday is 1).

Date.new(2001,2,3).cwday          #=> 6

Returns the day of week (0-6, Sunday is zero).

Date.new(2001,2,3).wday           #=> 6

Returns true if the date is Sunday.

Returns true if the date is Monday.

Returns true if the date is Tuesday.

Returns true if the date is Wednesday.

Returns true if the date is Thursday.

Returns true if the date is Friday.

Returns the Julian day number denoting the day of calendar reform.

Date.new(2001,2,3).start                  #=> 2299161.0
Date.new(2001,2,3,Date::GREGORIAN).start  #=> -Infinity

This method is equivalent to new_start(Date::ITALY).

Creates a new Time object with the value given by time, the given number of seconds_with_frac, or seconds and microseconds_with_frac since the Epoch. seconds_with_frac and microseconds_with_frac can be an Integer, Float, Rational, or other Numeric.

If in argument is given, the result is in that timezone or UTC offset, or if a numeric argument is given, the result is in local time. The in argument accepts the same types of arguments as tz argument of Time.new: string, number of seconds, or a timezone object.

Time.at(0)                                #=> 1969-12-31 18:00:00 -0600
Time.at(Time.at(0))                       #=> 1969-12-31 18:00:00 -0600
Time.at(946702800)                        #=> 1999-12-31 23:00:00 -0600
Time.at(-284061600)                       #=> 1960-12-31 00:00:00 -0600
Time.at(946684800.2).usec                 #=> 200000
Time.at(946684800, 123456.789).nsec       #=> 123456789
Time.at(946684800, 123456789, :nsec).nsec #=> 123456789

Time.at(1582721899, in: "+09:00")         #=> 2020-02-26 21:58:19 +0900
Time.at(1582721899, in: "UTC")            #=> 2020-02-26 12:58:19 UTC
Time.at(1582721899, in: "C")              #=> 2020-02-26 13:58:19 +0300
Time.at(1582721899, in: 32400)            #=> 2020-02-26 21:58:19 +0900

require 'tzinfo'
Time.at(1582721899, in: TZInfo::Timezone.get('Europe/Kiev'))
                                          #=> 2020-02-26 14:58:19 +0200

Returns the day of the month (1..31) for time.

t = Time.now   #=> 2007-11-19 08:27:03 -0600
t.day          #=> 19
t.mday         #=> 19

Returns the day of the month (1..31) for time.

t = Time.now   #=> 2007-11-19 08:27:03 -0600
t.day          #=> 19
t.mday         #=> 19

Returns an integer representing the day of the week, 0..6, with Sunday == 0.

t = Time.now   #=> 2007-11-20 02:35:35 -0600
t.wday         #=> 2
t.sunday?      #=> false
t.monday?      #=> false
t.tuesday?     #=> true
t.wednesday?   #=> false
t.thursday?    #=> false
t.friday?      #=> false
t.saturday?    #=> false

Returns an integer representing the day of the year, 1..366.

t = Time.now   #=> 2007-11-19 08:32:31 -0600
t.yday         #=> 323

Returns true if time represents Sunday.

t = Time.local(1990, 4, 1)       #=> 1990-04-01 00:00:00 -0600
t.sunday?                        #=> true

Returns true if time represents Monday.

t = Time.local(2003, 8, 4)       #=> 2003-08-04 00:00:00 -0500
t.monday?                        #=> true

Returns true if time represents Tuesday.

t = Time.local(1991, 2, 19)      #=> 1991-02-19 00:00:00 -0600
t.tuesday?                       #=> true

Returns true if time represents Wednesday.

t = Time.local(1993, 2, 24)      #=> 1993-02-24 00:00:00 -0600
t.wednesday?                     #=> true
Search took: 5ms  ·  Total Results: 1361