23件ヒット
[1-23件を表示]
(0.238秒)
ライブラリ
- ビルトイン (23)
キーワード
-
deconstruct
_ keys (1) -
to
_ a (11)
検索結果
-
Time
# wday -> Integer (26145.0) -
曜日を0(日曜日)から6(土曜日)の整数で返します。
...sun = Time.new(2017, 9, 17, 10, 34, 15, '+09:00') # => 2017-09-17 10:34:15 +0900
p sun.wday # => 0
p mon = Time.new(2017, 9, 18, 10, 34, 15, '+09:00') # => 2017-09-18 10:34:15 +0900
p mon.wday # => 1
p tue = Time.new(......p tue.wday # => 2
p wed = Time.new(2017, 9, 20, 10, 34, 15, '+09:00') # => 2017-09-20 10:34:15 +0900
p wed.wday # => 3
p thu = Time.new(2017, 9, 21, 10, 34, 15, '+09:00') # => 2017-09-21 10:34:15 +0900
p thu.wday......# => 4
p fri = Time.new(2017, 9, 22, 10, 34, 15, '+09:00') # => 2017-09-22 10:34:15 +0900
p fri.wday # => 5
p sat = Time.new(2017, 9, 23, 10, 34, 15, '+09:00') # => 2017-09-23 10:34:15 +0900
p sat.wday... -
Time
# deconstruct _ keys(array _ of _ names _ or _ nil) -> Hash (8026.0) -
パターンマッチに使用する名前と値の Hash を返します。
...ay
* :yday
* :wday
* :hour
* :min
* :sec
* :subsec
* :dst
* :zone
@param array_of_names_or_nil パターンマッチに使用する名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。
//emlist[例][ruby]{
t = Time.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 "working 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 (8008.0) -
時刻を10要素の配列で返します。
...整数 1-12)
* 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:0...