るりまサーチ

最速Rubyリファレンスマニュアル検索!
424件ヒット [1-100件を表示] (0.039秒)
トップページ > クエリ:y[x] > クエリ:year[x]

別のキーワード

  1. psych psych_y
  2. kernel y
  3. psych y
  4. kernel psych_y
  5. y syck

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

Time#year -> Integer (24207.0)

年を整数で返します。

...年を整数で返します。

//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5) # => 2000-01-02 03:04:05 +0900
p t.year # => 2000
//}...

Date#year -> Integer (24201.0)

年を返します。

年を返します。

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

n 年後を返します。

...

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

//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#>> も参照してく...

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

n 年前を返します。

...

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

//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#<< も参照してく...

Date#cwyear -> Integer (12200.0)

暦週における年を返します。

暦週における年を返します。

絞り込み条件を変える

MatchData#byteoffset(name) -> [Integer, Integer] | [nil, nil] (6118.0)

name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。

...][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.byteoffset('year') # => [0, 4]
p $~.byteoffset(:year) # => [0, 4]
p $~.byteoffset('month') # => [7, 8]
p $~.byteoffset(:month) # => [7, 8]
p $~.byteoffset('day') # => [nil, nil]
p $~.byteoff...
...set('century') # => `offset': undefined group name reference: century (IndexError)
//}

@see MatchData#offset...

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

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

...* :year
* :month
* :day
* :yday
* :wday

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

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

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

case d
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 d in Date(wday: 3, day: ..7)
puts "first Wednesday of the month"
end
//}

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

DateTime#deconstruct_keys(array_of_names_or_nil) -> Hash (6112.0)

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

...* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :sec_fraction
* :zone

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

//emlist[例][ruby]{
dt...
...dt in wday: 1..5, hour: 10..18 # deconstruct_keys が使われます
puts "Working time"
end
#=> "Working time" が出力される

case dt
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 mont...
...h 10" が出力される

# クラスのチェックと組み合わせて利用することもできます
if dt in DateTime(wday: 1..5, hour: 10..18, day: ..7)
puts "Working time, first week of the month"
end
//}

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

Time#deconstruct_keys(array_of_names_or_nil) -> Hash (6112.0)

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

...* :year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone

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

//emlist[例][ruby]{...
...30)

if 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 #{mont...
...h}"
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...

MatchData#byteoffset(n) -> [Integer, Integer] | [nil, nil] (6103.0)

n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。

n 番目の部分文字列のバイト単位のオフセットの
配列 [start, end] を返します。

n番目の部分文字列がマッチしていなければ [nil, nil] を返します。

@param n 部分文字列を指定する数値

@raise IndexError 範囲外の n を指定した場合に発生します。

@see MatchData#offset

絞り込み条件を変える

Psych::ScalarScanner#tokenize(string) -> object (3012.0)

YAML の scalar である文字列を Ruby のオブジェクトに変換した ものを返します。

...YAML の scalar である文字列を Ruby のオブジェクトに変換した
ものを返します。

scanner = Psych::ScalarScanner.new
p scanner.tokenize("yes") # => true
p scanner.tokenize("year") # => "year"
p scanner.tokenize("12") # => 12

@param string 変換文字列...

Time.parse(date, now = Time.now) {|year| year } -> Time (438.0)

...きで呼ばれた場合、dateの年はブロックによって変換されます。

require 'time'
Time.parse(...) {|y| y < 100 ? (y >= 69 ? y + 1900 : y + 2000) : y}

与えられた時刻に上位の要素がなかったり壊れていた場合、nowの
該当要素が使われます。...

Time.gm(sec, min, hour, mday, mon, year, wday, yday, isdst, zone) -> Time (411.0)

引数で指定した協定世界時の Time オブジェクトを返します。

...引数で指定した協定世界時の Time オブジェクトを返します。

引数の順序は Time#to_a と全く同じです。
引数 wday, yday, zone に指定した値は無視されます。
引数に nil を指定した場合の値はその引数がとり得る最小の値です。

@p...
...ram mday 日を 1 から 31 までの整数か文字列で指定します。

@param mon 1(1月)から 12(12月)の範囲の整数か文字列で指定します。
英語の月名("Jan", "Feb", ... などの省略名。文字の大小は無視)も指定できます。

@param year 年を...
...字列で指定します。例えば 1998 年に対して 1998 を指定します。

@param wday 無視されます。

@param yday 無視されます。

@param isdst 指定した日時が夏時間(Daylight Saving Time)なら true を指定します。
そうでないなら、false...
<< 1 2 3 ... > >>