るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Date#-(x) -> Rational | Date (18103.0)

x が日付オブジェクトなら、ふたつの差を Rational で返します。単位は日です。 あるいは x が数値ならば、self より x 日前の日付を返します。

x が日付オブジェクトなら、ふたつの差を Rational で返します。単位は日です。
あるいは
x が数値ならば、self より x 日前の日付を返します。

@param x 日数、あるいは日付オブジェクト
@raise TypeError x が数値でも日付オブジェクトでもない場合に発生します。

Date#<<(n) -> Date (198.0)

self より n ヶ月前の日付オブジェクトを返します。 n は数値でなければなりません。

...date'
Date
.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
Date
.new(2001,2,3) << -2 #=> #<Date: 2001-04-03 ...>
//}

対応する月に同じ日が存在しない時は、代わりにその月の末日が使われます。

//emlist[][ruby]{
require 'date'
Date
.new(2001,3,28) << 1 #=> #<Date...
...: 2001-02-28 ...>
Date
.new(2001,3,31) << 1 #=> #<Date: 2001-02-28 ...>
//}

このことは以下のように、もしかすると予期しない振る舞いをするかもしれません。

//emlist[][ruby]{
require 'date'
Date
.new(2001,3,31) << 2 #=> #<Date: 2001-01-31 ...>
Date
.new(200...
...1,3,31) << 1 << 1 #=> #<Date: 2001-01-28 ...>

Date
.new(2001,3,31) << 1 << -1 #=> #<Date: 2001-03-28 ...>
//}

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

@param n 月数...

Date#>>(n) -> Date (198.0)

self から n ヶ月後の日付オブジェクトを返します。 n は数値でなければなりません。

...ruby]{
require 'date'
Date
.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...>
Date
.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...>
//}


対応する月に同じ日が存在しない時は、代わりにその月の末日が使われます。

//emlist[][ruby]{
require 'date'
Date
.new(2001,1,28)...
...e: 2001-02-28 ...>
Date
.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...>
//}

このことは以下のように、もしかすると予期しない振る舞いをするかもしれません。

//emlist[][ruby]{
require 'date'
Date
.new(2001,1,31) >> 2 #=> #<Date: 2001-03-31 ...>
Date
.new(20...
...01,1,31) >> 1 >> 1 #=> #<Date: 2001-03-28 ...>

Date
.new(2001,1,31) >> 1 >> -1 #=> #<Date: 2001-01-28 ...>
//}

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

@param n 月数...

Date#next_year(n = 1) -> Date (138.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 (138.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 (125.0)

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

...逆なら -1 を返します。

other は日付オブジェクトか、
天文学的なユリウス日をあらわす数値を指定します。
そうでない場合、比較ができないので nil を返します。

//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(4903887, 2) # => 0
//}

@param other 日付オブジェクトまたは数値...

Date#cwday -> Integer (118.0)

暦週の日 (曜日) を返します (1-7、月曜は1)。

...暦週の日 (曜日) を返します (1-7、月曜は1)。...

Date#cweek -> Integer (118.0)

暦週を返します (1-53)。

...暦週を返します (1-53)。...

Date#day -> Integer (118.0)

月の日を返します (1-31)。

...月の日を返します (1-31)。...
<< 1 2 3 ... > >>