るりまサーチ

最速Rubyリファレンスマニュアル検索!
708件ヒット [1-100件を表示] (0.095秒)
トップページ > クエリ:r[x] > クラス:Time[x]

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Time#hour -> Integer (6201.0)

時を整数で返します。

...時を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.hour # => 3
//}...

Time#year -> Integer (6201.0)

年を整数で返します。

...年を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.year # => 2000
//}...

Time#strftime(format) -> String (6125.0)

時刻を format 文字列に従って文字列に変換した結果を返します。

...時刻を format 文字列に従って文字列に変換した結果を返します。

@param format フォーマット文字列を指定します。使用できるものは 以下の通りです。

* %A: 曜日の名称(Sunday, Monday ... )
* %a: 曜日の省略名(Sun, Mon ... )
* %B: 月...
...の名称(January, February ... )
* %b: 月の省略名(Jan, Feb ... )
* %C: 世紀 (2009年であれば 20)
* %c: 日付と時刻 (%a %b %e %T %Y)
* %D: 日付 (%m/%d/%y)
* %d: 日(01-31)
* %e: 日。一桁の場合、半角空白で埋める ( 1..31)
* %F: %Y-%m-%d と同等 (ISO 860...
...または午後(AM,PM)
* %Q: 1970-01-01 00:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p と同等。
* %S: 秒(00-60) (60はうるう...

Time#to_r -> Rational (6108.0)

起算時からの経過秒数を有理数で返します。1 秒に満たない経過も 表現されます。

...起算時からの経過秒数を有理数で返します。1 秒に満たない経過も
表現されます。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p t # => 2000-01-02 03:04:05 +0900
p t.to_r # => (473374922500003/500000)
//}...

Time#floor(ndigits=0) -> Time (6107.0)

十進小数点数で指定した桁数の精度で切り捨てをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で切り捨てます)。

...その Time オブジェクトを返します。
(デフォルトは0、つまり小数点の所で切り捨てます)。

ndigits には 0 以上の整数を渡します。

@param ndigits 十進での精度(桁数)

//emlist[][ruby]{
r
equire 'time'

t = Time.utc(2010,3,30, 5,43,25.123456789r)
t.is...
...3:25.1234567890Z"
t.floor.iso8601(10) # => "2010-03-30T05:43:25.0000000000Z"
t.floor(0).iso8601(10) # => "2010-03-30T05:43:25.0000000000Z"
t.floor(1).iso8601(10) # => "2010-03-30T05:43:25.1000000000Z"
t.floor(2).iso8601(10) # => "2010-03-30T05:43:25.1200000000Z"
t.floor(3).iso8601(10) # => "...
...loor(4).iso8601(10) # => "2010-03-30T05:43:25.1234000000Z"

t = Time.utc(1999,12,31, 23,59,59)
(t + 0.4).floor.iso8601(3) # => "1999-12-31T23:59:59.000Z"
(t + 0.9).floor.iso8601(3) # => "1999-12-31T23:59:59.000Z"
(t + 1.4).floor.iso8601(3) # => "2000-01-01T00:00:00.000Z"
(t + 1.9).floor.is...

絞り込み条件を変える

Time#deconstruct_keys(array_of_names_or_nil) -> Hash (6101.0)

パターンマッチに使用する名前と値の Hash を返します。

...* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone

@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{...
.....7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of the month" が出力される

case t
in year: ...2022
puts "too old"
in month: ..9
puts "quarter 1-3"
in wday: 1..5, month:
puts "working day in month #{month}"
end
#=> "working day in...
...month 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if t in Time(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}

@see d:spec/pattern_matching#matching_non_primitive_objects...

Time#friday? -> bool (6101.0)

self の表す時刻が金曜日である場合に true を返します。 そうでない場合に false を返します。

...self の表す時刻が金曜日である場合に true を返します。
そうでない場合に false を返します。

//emlist[][ruby]{
t = Time.local(1987, 12, 18) # => 1987-12-18 00:00:00 +0900
p t.friday? # => true
//}...

Time#rfc2822 -> String (6101.0)

2822 で定義されている date-time として表現される形式の文字列を 返します。

...されている date-time として表現される形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss zone
//}
ただし zone は [+-]hhmm です。
self が UTC time の場合、zone は +0...
...000 になります。

使用例
r
equire 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.rfc2822 #=> "Sun, 31 Aug 2008 03:34:56 -0000"...

Time#rfc822 -> String (6101.0)

2822 で定義されている date-time として表現される形式の文字列を 返します。

...されている date-time として表現される形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss zone
//}
ただし zone は [+-]hhmm です。
self が UTC time の場合、zone は +0...
...000 になります。

使用例
r
equire 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.rfc2822 #=> "Sun, 31 Aug 2008 03:34:56 -0000"...

Time#round(ndigits=0) -> Time (6101.0)

十進小数点数で指定した桁数の精度で丸めをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で丸めます)。

...その Time オブジェクトを返します。
(デフォルトは0、つまり小数点の所で丸めます)。

ndigits には 0 以上の整数を渡します。

@param ndigits 十進での精度(桁数)

//emlist[][ruby]{
r
equire 'time'

t = Time.utc(1999,12,31, 23,59,59)
p((t + 0.4).round.i...
....000Z"
p((t + 0.49).round.iso8601(3)) # => "1999-12-31T23:59:59.000Z"
p((t + 0.5).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.4).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.49).round.iso8601(3)) # => "2000-01-01T00:00:00.000Z"
p((t + 1.5).round.iso8601(3))...
...# => "2000-01-01T00:00:01.000Z"

t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}...
...# => "2000-01-01T00:00:01.000Z"

t = Time.utc(1999,12,31, 23,59,59)
p (t + 0.123456789).round(4).iso8601(6) # => "1999-12-31T23:59:59.123500Z"
//}

@see Time#ceil, Time#floor...

絞り込み条件を変える

<< 1 2 3 ... > >>