476件ヒット
[1-100件を表示]
(0.124秒)
ライブラリ
- ビルトイン (404)
-
json
/ add / time (12) - time (60)
キーワード
- <=> (12)
- asctime (12)
- ceil (6)
- ctime (12)
- day (12)
-
deconstruct
_ keys (2) - floor (6)
-
gmt
_ offset (12) - gmtoff (12)
- hash (12)
- hour (12)
- httpdate (12)
- inspect (6)
- iso8601 (12)
- mday (12)
- min (12)
- mon (12)
- monday? (12)
- month (12)
- nsec (12)
- rfc2822 (12)
- rfc822 (12)
- round (12)
- sec (12)
- strftime (12)
- subsec (12)
- sunday? (12)
-
to
_ i (12) -
to
_ json (12) -
to
_ r (12) -
to
_ s (12) -
tv
_ nsec (12) -
tv
_ sec (12) -
tv
_ usec (12) - usec (12)
-
utc
_ offset (12) - wday (12)
- wednesday? (12)
- xmlschema (12)
- yday (12)
- year (12)
- zone (12)
検索結果
先頭5件
-
Time
# month -> Integer (6202.0) -
月を整数で返します。
...月を整数で返します。
//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.month # => 1
p t.mon # => 1
//}... -
Time
# round(ndigits=0) -> Time (6202.0) -
十進小数点数で指定した桁数の精度で丸めをし、 その Time オブジェクトを返します。 (デフォルトは0、つまり小数点の所で丸めます)。
...の Time オブジェクトを返します。
(デフォルトは0、つまり小数点の所で丸めます)。
ndigits には 0 以上の整数を渡します。
@param ndigits 十進での精度(桁数)
//emlist[][ruby]{
require 'time'
t = Time.utc(1999,12,31, 23,59,59)
p((t + 0.4).round.iso8......0Z"
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... -
Time
# inspect -> String (6114.0) -
時刻を文字列に変換した結果を返します。
...返します。
Time#to_s とは異なりナノ秒まで含めて返します。
//emlist[][ruby]{
t = Time.now
t.inspect #=> "2012-11-10 18:16:12.261257655 +0100"
t.strftime "%Y-%m-%d %H:%M:%S.%N %z" #=> "2012-11-10 18:16:12.261257655 +0100"
t.utc.inspect......#=> "2012-11-10 17:16:12.261257655 UTC"
t.strftime "%Y-%m-%d %H:%M:%S.%N UTC" #=> "2012-11-10 17:16:12.261257655 UTC"
//}
戻り値の文字エンコーディングは Encoding::US_ASCII です。... -
Time
# to _ json(*args) -> String (6108.0) -
自身を JSON 形式の文字列に変換して返します。
...身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_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
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6102.0) -
パターンマッチに使用する名前と値の Hash を返します。
...:month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
t = Time.utc......t in wday: 3, day: ..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
# min -> Integer (6102.0) -
分を整数で返します。
...分を整数で返します。
//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.min # => 4
//}... -
Time
# mon -> Integer (6102.0) -
月を整数で返します。
...月を整数で返します。
//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.month # => 1
p t.mon # => 1
//}... -
Time
# monday? -> bool (6102.0) -
self の表す時刻が月曜日である場合に true を返します。 そうでない場合に false を返します。
...self の表す時刻が月曜日である場合に true を返します。
そうでない場合に false を返します。
//emlist[][ruby]{
t = Time.local(2003, 8, 4) # => 2003-08-04 00:00:00 +0900
p t.monday? # => true
//}... -
Time
# nsec -> Integer (6102.0) -
時刻のナノ秒の部分を整数で返します。
...//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p "%10.9f" % t.to_f # => "946749845.000005960"
p t.nsec # => 6000
//}
IEEE 754 浮動小数点数で表現できる精度が違うため、Time#to_fの最小
の桁とnsecの最小の桁は異なります。nsecで表される値... -
Time
# sunday? -> bool (6102.0) -
self の表す時刻が日曜日である場合に true を返します。 そうでない場合に false を返します。
...self の表す時刻が日曜日である場合に true を返します。
そうでない場合に false を返します。
//emlist[][ruby]{
t = Time.local(1990, 4, 1) # => 1990-04-01 00:00:00 +0900
p t.sunday? # => true
//}...