るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

キーワード

検索結果

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

n 年後を返します。

...す。

self >> (n * 12) に相当します。

//emlist[例][ruby]{
r
equire '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 (6244.0)

n 年前を返します。

...す。

self << (n * 12) に相当します。

//emlist[例][ruby]{
r
equire '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#to_json(*args) -> String (302.0)

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

...ら JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

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

//emlist[例][ruby]{
r
equire "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...