time 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/.rdoc_options +2 -0
- data/README.md +7 -5
- data/lib/time.rb +15 -11
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc9964ca1d565e8395c46c83ffcf74b0a69ba3655dae9869a1a90f349b8d6586
|
|
4
|
+
data.tar.gz: c7500638e2132c8d5ed66243bea7d3e93f52933ecd504e159385a788e4682bc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28c4cdaa51d8060a1ba0282fbe6d49e5f1b7574e693631fe2fd038503bc26a1e95004e8e931a908bdd3b8af11e7018307541e40163d62898422319d07ff40c02
|
|
7
|
+
data.tar.gz: 68b674ba7b85e2f7a2bb731bf89f515b81fcda6a5dd3501e8f1debb9bda574a530c6941fce013179ea54d91e8ddbf53ab1e7c1312226098bc17a10cb9a57bee5
|
data/.document
ADDED
data/.rdoc_options
ADDED
data/README.md
CHANGED
|
@@ -8,13 +8,16 @@ and converting Times.
|
|
|
8
8
|
This library extends the Time class with the following conversions between
|
|
9
9
|
date strings and Time objects:
|
|
10
10
|
|
|
11
|
-
* date-time defined by
|
|
12
|
-
* HTTP-date defined by
|
|
13
|
-
* dateTime defined by XML Schema Part 2: Datatypes (
|
|
14
|
-
8601}[http://www.iso.org/iso/date_and_time_format])
|
|
11
|
+
* date-time defined by [RFC 2822]
|
|
12
|
+
* HTTP-date defined by [RFC 2616]
|
|
13
|
+
* dateTime defined by XML Schema Part 2: Datatypes ([ISO 8601])
|
|
15
14
|
* various formats handled by Date._parse
|
|
16
15
|
* custom formats handled by Date._strptime
|
|
17
16
|
|
|
17
|
+
[RFC 2822]: http://www.ietf.org/rfc/rfc2822.txt
|
|
18
|
+
[RFC 2616]: http://www.ietf.org/rfc/rfc2616.txt
|
|
19
|
+
[ISO 8601]: http://www.iso.org/iso/date_and_time_format
|
|
20
|
+
|
|
18
21
|
## Installation
|
|
19
22
|
|
|
20
23
|
Add this line to your application's Gemfile:
|
|
@@ -51,4 +54,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
51
54
|
## Contributing
|
|
52
55
|
|
|
53
56
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/time.
|
|
54
|
-
|
data/lib/time.rb
CHANGED
|
@@ -24,9 +24,10 @@ require 'date'
|
|
|
24
24
|
|
|
25
25
|
# :startdoc:
|
|
26
26
|
|
|
27
|
+
# #
|
|
27
28
|
class Time
|
|
28
29
|
|
|
29
|
-
VERSION = "0.4.
|
|
30
|
+
VERSION = "0.4.2" # :nodoc:
|
|
30
31
|
|
|
31
32
|
class << Time
|
|
32
33
|
|
|
@@ -79,7 +80,7 @@ class Time
|
|
|
79
80
|
#
|
|
80
81
|
# You must require 'time' to use this method.
|
|
81
82
|
#
|
|
82
|
-
def zone_offset(zone, year=
|
|
83
|
+
def zone_offset(zone, year=nil)
|
|
83
84
|
off = nil
|
|
84
85
|
zone = zone.upcase
|
|
85
86
|
if /\A([+-])(\d\d)(:?)(\d\d)(?:\3(\d\d))?\z/ =~ zone
|
|
@@ -88,10 +89,13 @@ class Time
|
|
|
88
89
|
off = zone.to_i * 3600
|
|
89
90
|
elsif ZoneOffset.include?(zone)
|
|
90
91
|
off = ZoneOffset[zone] * 3600
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
else
|
|
93
|
+
year ||= self.now.year
|
|
94
|
+
if ((t = self.local(year, 1, 1)).zone.upcase == zone rescue false)
|
|
95
|
+
off = t.utc_offset
|
|
96
|
+
elsif ((t = self.local(year, 7, 1)).zone.upcase == zone rescue false)
|
|
97
|
+
off = t.utc_offset
|
|
98
|
+
end
|
|
95
99
|
end
|
|
96
100
|
off
|
|
97
101
|
end
|
|
@@ -280,7 +284,7 @@ class Time
|
|
|
280
284
|
#
|
|
281
285
|
# This method **does not** function as a validator. If the input
|
|
282
286
|
# string does not match valid formats strictly, you may get a
|
|
283
|
-
# cryptic result. Should consider to use
|
|
287
|
+
# cryptic result. Should consider to use Time.strptime instead
|
|
284
288
|
# of this method as possible.
|
|
285
289
|
#
|
|
286
290
|
# require 'time'
|
|
@@ -391,7 +395,7 @@ class Time
|
|
|
391
395
|
# heuristic to detect the format of the input string, you provide
|
|
392
396
|
# a second argument that describes the format of the string.
|
|
393
397
|
#
|
|
394
|
-
# Raises
|
|
398
|
+
# Raises ArgumentError if the date or format is invalid.
|
|
395
399
|
#
|
|
396
400
|
# If a block is given, the year described in +date+ is converted by the
|
|
397
401
|
# block. For example:
|
|
@@ -407,7 +411,7 @@ class Time
|
|
|
407
411
|
# %c :: The preferred local date and time representation
|
|
408
412
|
# %C :: Century (20 in 2009)
|
|
409
413
|
# %d :: Day of the month (01..31)
|
|
410
|
-
# %D :: Date (%m/%d/%y)
|
|
414
|
+
# %D :: \Date (%m/%d/%y)
|
|
411
415
|
# %e :: Day of the month, blank-padded ( 1..31)
|
|
412
416
|
# %F :: Equivalent to %Y-%m-%d (the ISO 8601 date format)
|
|
413
417
|
# %g :: The last two digits of the commercial year
|
|
@@ -444,8 +448,8 @@ class Time
|
|
|
444
448
|
# %X :: Preferred representation for the time alone, no date
|
|
445
449
|
# %y :: Year without a century (00..99)
|
|
446
450
|
# %Y :: Year which may include century, if provided
|
|
447
|
-
# %z :: Time zone as
|
|
448
|
-
# %Z :: Time zone name
|
|
451
|
+
# %z :: \Time zone as hour offset from UTC (e.g. +0900)
|
|
452
|
+
# %Z :: \Time zone name
|
|
449
453
|
# %% :: Literal "%" character
|
|
450
454
|
# %+ :: date(1) (%a %b %e %H:%M:%S %Z %Y)
|
|
451
455
|
#
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: time
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tanaka Akira
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2025-12-17 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: date
|
|
@@ -30,6 +30,8 @@ executables: []
|
|
|
30
30
|
extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
|
32
32
|
files:
|
|
33
|
+
- ".document"
|
|
34
|
+
- ".rdoc_options"
|
|
33
35
|
- BSDL
|
|
34
36
|
- COPYING
|
|
35
37
|
- README.md
|
|
@@ -55,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
57
|
- !ruby/object:Gem::Version
|
|
56
58
|
version: '0'
|
|
57
59
|
requirements: []
|
|
58
|
-
rubygems_version: 3.6.
|
|
60
|
+
rubygems_version: 3.6.9
|
|
59
61
|
specification_version: 4
|
|
60
62
|
summary: Extends the Time class with methods for parsing and conversion.
|
|
61
63
|
test_files: []
|