るりまサーチ

最速Rubyリファレンスマニュアル検索!
122件ヒット [1-100件を表示] (0.030秒)

別のキーワード

  1. optparse on
  2. optionparser on
  3. tracer on
  4. thread abort_on_exception
  5. socket udp_server_loop_on

ライブラリ

キーワード

検索結果

<< 1 2 > >>

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.ut...
...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#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#month -> 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#to_json(*args) -> String (6102.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#zone -> String (6102.0)

タイムゾーンを表す文字列を返します。

...タイムゾーンを表す文字列を返します。

//emlist[][ruby]{
p Time.now.zone # => "JST"
//}...

Time#iso8601(fractional_seconds = 0) -> String (202.0)

XML Schema で定義されている dateTime として 表現される形式の文字列を返します。

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

XML Schema で定義されている dateTime として
表現される形式の文字列をパースするためのクラスメソッド
Time
.iso8601, Time.xmlschema もあります。

@param fractional_seconds 小数点...
...ただし TZD は Z または [+-]hh:mm です。

使用例
require 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.xmlschema #=> "2008-08-31T03:34:56Z"
p t.xmlschema(9) #=> "2008-08-31T03:34:56.000000000Z"

@see Time.iso8601, Time.xmlschema...

Time#xmlschema(fractional_seconds = 0) -> String (202.0)

XML Schema で定義されている dateTime として 表現される形式の文字列を返します。

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

XML Schema で定義されている dateTime として
表現される形式の文字列をパースするためのクラスメソッド
Time
.iso8601, Time.xmlschema もあります。

@param fractional_seconds 小数点...
...ただし TZD は Z または [+-]hh:mm です。

使用例
require 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.xmlschema #=> "2008-08-31T03:34:56Z"
p t.xmlschema(9) #=> "2008-08-31T03:34:56.000000000Z"

@see Time.iso8601, Time.xmlschema...

Time#subsec -> Integer | Rational (102.0)

時刻を表す分数を返します。

...時刻を表す分数を返します。

Rational を返す場合があります。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5,6)
p "%10.9f" % t.to_f # => "946749845.000005960"
p t.subsec #=> (3/500000)
//}

to_f の値と subsec の値の下のほうの桁の値は異なる場...

Time#to_r -> Rational (102.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)
//}...

絞り込み条件を変える

<< 1 2 > >>