132件ヒット
[1-100件を表示]
(0.140秒)
クラス
- Date (50)
- DateTime (2)
- MatchData (30)
-
Psych
:: ScalarScanner (12) - Time (38)
キーワード
- byteoffset (6)
- cwyear (12)
-
deconstruct
_ keys (6) -
next
_ year (12) - offset (24)
-
prev
_ year (12) - strftime (12)
-
to
_ a (12) - tokenize (12)
検索結果
先頭5件
-
Time
# year -> Integer (21220.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 (21202.0) -
年を返します。
年を返します。 -
Date
# next _ year(n = 1) -> Date (12220.0) -
n 年後を返します。
...(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#>> も参照してください。
@... -
Time
# strftime(format) -> String (9591.0) -
時刻を format 文字列に従って文字列に変換した結果を返します。
...時刻を format 文字列に従って文字列に変換した結果を返します。
@param format フォーマット文字列を指定します。使用できるものは 以下の通りです。
* %A: 曜日の名称(Sunday, Monday ... )
* %a: 曜日の省略名(Sun, Mon ... )
* %B: 月......の名称(January, February ... )
* %b: 月の省略名(Jan, Feb ... )
* %C: 世紀 (2009年であれば 20)
* %c: 日付と時刻 (%a %b %e %T %Y)
* %D: 日付 (%m/%d/%y)
* %d: 日(01-31)
* %e: 日。一桁の場合、半角空白で埋める ( 1..31)
* %F: %Y-%m-%d と同等 (ISO 860......0:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p と同等。
* %S: 秒(00-60) (60はうるう秒)
* %s: 1970-01-01 00:00:00 UTC から... -
Date
# prev _ year(n = 1) -> Date (9220.0) -
n 年前を返します。
...(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 (9201.0) -
暦週における年を返します。
暦週における年を返します。 -
MatchData
# byteoffset(name) -> [Integer , Integer] | [nil , nil] (6319.0) -
name という名前付きグループに対応する部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...name という名前付きグループに対応する部分文字列のバイト単位のオフセットの
配列 [start, end] を返します。
nameの名前付きグループにマッチした部分文字列がなければ
[nil, nil] を返します。
@param name 名前(シンボルか文字......ます。
//emlist[例][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 $~.byteoffset('century') # => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#offset... -
MatchData
# byteoffset(n) -> [Integer , Integer] | [nil , nil] (6304.0) -
n 番目の部分文字列のバイト単位のオフセットの 配列 [start, end] を返します。
...のオフセットの
配列 [start, end] を返します。
n番目の部分文字列がマッチしていなければ [nil, nil] を返します。
@param n 部分文字列を指定する数値
@raise IndexError 範囲外の n を指定した場合に発生します。
@see MatchData#offset... -
Time
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (6137.0) -
パターンマッチに使用する名前と値の Hash を返します。
...:year
* :month
* :day
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
t......me.utc(2022, 10, 5, 21, 25, 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 "......ng 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
# to _ a -> Array (6131.0) -
時刻を10要素の配列で返します。
... year: 年 (整数 2000年=2000)
* wday: 曜日 (整数 0-6)
* yday: 年内通算日 (整数 1-366)
* isdst: 夏時間であるかどうか (true/false)
* zone: タイムゾーン (文字列)
//emlist[][ruby]{
t = Time.local(2000,1,2,3,4,5)
p t # => 2000-01-02 03:04:05 +0900
p t.t......4, 3, 2, 1, 2000, 0, 2, false, "JST"]
//}
要素の順序は C 言語の tm 構造体に合わせています。ただし、
tm 構造体に zone はありません。
注意: C 言語の tm 構造体とは異なり、month は 1 月に対
して 1 を返し、year は 1998 年に対して 1998... -
MatchData
# offset(name) -> [Integer , Integer] | [nil , nil] (6119.0) -
name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返 します。
...name という名前付きグループに対応する部分文字列のオフセットの配列 [start, end] を返
します。
//emlist[例][ruby]{
[ self.begin(name), self.end(name) ]
//}
と同じです。nameの名前付きグループにマッチした部分文字列がなければ
[nil, ni......emlist[例][ruby]{
/(?<year>\d{4})年(?<month>\d{1,2})月(?:(?<day>\d{1,2})日)?/ =~ "2021年1月"
p $~.offset('year') # => [0, 4]
p $~.offset(:year) # => [0, 4]
p $~.offset('month') # => [5, 6]
p $~.offset(:month) # => [5, 6]
p $~.offset('day') # => [nil, nil]
p $~.offset('century')......# => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end......# => `offset': undefined group name reference: century (IndexError)
//}
@see MatchData#begin, MatchData#end, MatchData#offset...