るりまサーチ (Ruby 3.4)

最速Rubyリファレンスマニュアル検索!
9件ヒット [1-9件を表示] (0.158秒)
トップページ > クエリ:r[x] > クエリ:ruby[x] > クラス:Date[x] > バージョン:3.4[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

Date.json_create(hash) -> Date (18352.0)

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

@param hash 適切なキーを持つハッシュを指定します。

Date#deconstruct_keys(array_of_names_or_nil) -> Hash (18322.0)

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

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

//emlist[例][ruby]{
d = Date.new(2022, 10, 5)

if d in wday: 3, day: ..7 # deconstruct_keys が使われます
puts "first Wednesday of the month"
end
#=> "first Wednesday of...
...g day in month #{month}"
end
#=> "working day in month 10" が出力される

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

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

Date#next_year(n = 1) -> Date (18322.0)

n 年後を返します。

...相当します。

//emlist[例][ruby]{
require 'date'
Date
.new(2001,2,3).next_year #=> #<Date: 2002-02-03 ...>
Date
.new(2008,2,29).next_year #=> #<Date: 2009-02-28 ...>
Date
.new(2008,2,29).next_year(4) #=> #<Date: 2012-02-29 ...>
//}

Date
#>> も参照してください。

@param n 年...

Date#prev_year(n = 1) -> Date (18322.0)

n 年前を返します。

...相当します。

//emlist[例][ruby]{
require 'date'
Date
.new(2001,2,3).prev_year #=> #<Date: 2000-02-03 ...>
Date
.new(2008,2,29).prev_year #=> #<Date: 2007-02-28 ...>
Date
.new(2008,2,29).prev_year(4) #=> #<Date: 2004-02-29 ...>
//}

Date
#<< も参照してください。

@param n 年...

Date#<=>(other) -> -1 | 0 | 1 | nil (322.0)

二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。

...

//emlist[][ruby]{
require "date"

p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 4) # => -1
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 3) # => 0
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 2) # => 1
p Date.new(2001, 2, 3) <=> Object.new # => nil
p Date.new(2001, 2, 3) <=> Rational(49...

絞り込み条件を変える

Date#to_json(*args) -> String (322.0)

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

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

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

Date
.today.to_json
# => "{\"json_class\":\"Date\",\"y\":2018,\"m\":12,\"d\":11,\"sg\":2299161.0}"
//}

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

Date.civil(year = -4712, mon = 1, mday = 1, start = Date::ITALY) -> Date (322.0)

暦日付に相当する日付オブジェクトを生成します。

...す。
省略した場合は、Date::ITALY (1582年10月15日) になります。

Date
.jd も参照してください。

@param year 年
@param mon 月
@param mday 日
@param start グレゴリオ暦をつかい始めた日をあらわすユリウス日
@raise Date::Error 正しくない日付に...
...なる組み合わせである場合に発生します。

//emlist[例][ruby]{
require 'date'
Date
.new(2017, 9, 20) # => #<Date: 2017-09-20 ...>
//}...

Date.new(year = -4712, mon = 1, mday = 1, start = Date::ITALY) -> Date (322.0)

暦日付に相当する日付オブジェクトを生成します。

...す。
省略した場合は、Date::ITALY (1582年10月15日) になります。

Date
.jd も参照してください。

@param year 年
@param mon 月
@param mday 日
@param start グレゴリオ暦をつかい始めた日をあらわすユリウス日
@raise Date::Error 正しくない日付に...
...なる組み合わせである場合に発生します。

//emlist[例][ruby]{
require 'date'
Date
.new(2017, 9, 20) # => #<Date: 2017-09-20 ...>
//}...

Date.today(start = Date::ITALY) -> Date (322.0)

現在の日付に相当する日付オブジェクトを生成します。

...現在の日付に相当する日付オブジェクトを生成します。

@param start グレゴリオ暦をつかい始めた日をあらわすユリウス日

//emlist[例][ruby]{
require 'date'
Date
.today # => #<Date: 2017-09-20 ...>
//}...