るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. fileutils rm_r
  5. fileutils cp_r

ライブラリ

クラス

キーワード

検索結果

Time#month -> Integer (24314.0)

月を整数で返します。

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

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

Time#rfc2822 -> String (23253.0)

2822 で定義されている date-time として表現される形式の文字列を 返します。

...されている date-time として表現される形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss zone
//}
ただし zone は [+-]hhmm です。
self が UTC time の場合、zone は +0...
...000 になります。

使用例
r
equire 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.rfc2822 #=> "Sun, 31 Aug 2008 03:34:56 -0000"...

Time#rfc822 -> String (23253.0)

2822 で定義されている date-time として表現される形式の文字列を 返します。

...されている date-time として表現される形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss zone
//}
ただし zone は [+-]hhmm です。
self が UTC time の場合、zone は +0...
...000 になります。

使用例
r
equire 'time'

iso8601_time = '2008-08-31T12:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.rfc2822 #=> "Sun, 31 Aug 2008 03:34:56 -0000"...

Time#strftime(format) -> String (21481.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...
...または午後(AM,PM)
* %Q: 1970-01-01 00:00:00 UTC からの経過ミリ秒 (Time#strftime は対応していませんが、Date#strftime で使えます)
* %R: 24時間制の時刻。%H:%M と同等。
* %r: 12時間制の時刻。%I:%M:%S %p と同等。
* %S: 秒(00-60) (60はうるう...

Time#httpdate -> String (17231.0)

2616 で定義されている HTTP-date の rfc1123-date 形式の文字列を 返します。

...る HTTP-date の rfc1123-date 形式の文字列を
返します。

@return 以下の形式の文字列を返します。
//emlist{
day-of-week, DD month-name CCYY hh:mm:ss GMT
//}
注意: 結果はいつも UTC (GMT) です。

使用例
r
equire 'time'

iso8601_time = '2008-08-31T12...
...:34:56+09:00'
t = Time.iso8601(iso8601_time)
p t.httpdate #=> "Sun, 31 Aug 2008 03:34:56 GMT"...

絞り込み条件を変える

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

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

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

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

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

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

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

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

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

//emlist[例][ruby]{
dt...
...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 month 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#mon -> Integer (9214.0)

月を整数で返します。

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

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

Time#to_a -> Array (9213.0)

時刻を10要素の配列で返します。

...hour: 時 (整数 0-23)
* mday: 日 (整数)
* mon: 月 (整数 1-12)
* year: 年 (整数 2000年=2000)
* wday: 曜日 (整数 0-6)
* yday: 年内通算日 (整数 1-366)
* isdst: 夏時間であるかどうか (true/false)
* zone: タイムゾーン (文字列)

//emlist[][rub...
...y]{
t = Time.local(2000,1,2,3,4,5)
p t # => 2000-01-02 03:04:05 +0900
p t.to_a # => [5, 4, 3, 2, 1, 2000, 0, 2, false, "JST"]
//}

要素の順序は C 言語の tm 構造体に合わせています。ただし、
tm 構造体に zone はありません。

注意: C 言語の tm 構造体と...
...は異なり、month は 1 月に対
して 1 を返し、year は 1998 年に対して 1998 を返します。また、
yday は 1 から数えます。...