るりまサーチ (Ruby 2.6.0)

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.121秒)
トップページ > クエリ:r[x] > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クラス:Time[x] > バージョン:2.6.0[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

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

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

...または午後(am,pm)
* %p: 午前または午後(AM,PM)
* %Q: 1970-01-01 00:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p と同等...
...セット (例 +09:00:00)
* %%: %自身
* %+: date(1)の形式 (%a %b %e %H:%M:%S %Z %Y) (Time#strftime は対応していませんが、Date#strftime で使えます)

このメソッドは strftime(3) や glibcの仕様を参考に作成されており、以下のオプションが利用でき...
...uby]{
p t = Time.new(2001,2,3,4,5,6,"+09:00") # => 2001-02-03 04:05:06 +0900
p t.strftime("Printed on %m/%d/%Y") # => "Printed on 02/03/2001"
p t.strftime("Printed on %m/%-d/%_6Y") # => "Printed on 02/3/ 2001"
p t.strftime("at %I:%M%p") # => "at 04:05AM"
p t.strftime("at %I:%M...

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

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

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

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

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

//emlist[][ruby]{
require 'time'

t = Time.utc(1999,12,31, 23,59,59)...
...ound.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"
//}...

Time#<=>(other) -> -1 | 0 | 1 | nil (361.0)

self と other の時刻を比較します。self の方が大きい場合は 1 を、等しい場合は 0 を、 小さい場合は -1 を返します。比較できない場合は、nil を返します。

...たい時刻を Time オブジェクトで指定します。

//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t2 = t + 2592000 # => 2000-01-31 00:00:00 +0900
p t <=> t2 # => -1
p t2 <=> t # => 1
//}

//emlist[][ruby]{
p t = Time.local(2000)...

Time#to_json(*args) -> String (361.0)

自身を JSON 形式の文字列に変換して返します。

...す。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。

//emlist[例][ruby]{
require "json/add/core"

Time
.now.to_json # => "{\"json_class\":\"Time\",\"s\":1544968675,\"n\":676167000}"
//}

@see JSON::Generator::GeneratorMethods::Hash#to_json...

Time#+(other) -> Time (343.0)

self より other 秒だけ後の時刻を返します。

...self より other 秒だけ後の時刻を返します。

@param other 自身からの秒数を数値で指定します。

//emlist[][ruby]{
p t = Time.local(2000) # => 2000-01-01 00:00:00 +0900
p t + (60 * 60 * 24) # => 2000-01-02 00:00:00 +0900
//}...

絞り込み条件を変える

Time#eql?(other) -> bool (343.0)

other が Time かそのサブクラスのインスタンスであり自身と時刻が等しい場合に true を返します。そうでない場合に false を返します。

...er が Time かそのサブクラスのインスタンスであり自身と時刻が等しい場合に
true を返します。そうでない場合に false を返します。

@param other 自身と比較したい時刻を Time オブジェクトを指定します。

//emlist[][ruby]{
p Time.local...
...(2000, 1, 1).eql?(Time.local(2000, 1, 1)) # => true
p Time.local(2000, 1, 1).eql?(Time.local(2000, 1, 2)) # => false
//}...