Issue #14034 has been reported by jeremyevans0 (Jeremy Evans).

----------------------------------------
Bug #14034: Time.parse does not handle timezone offsets with seconds
https://bugs.ruby-lang.org/issues/14034

* Author: jeremyevans0 (Jeremy Evans)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0dev (2017-10-19 trunk 60215) [x86_64-openbsd]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
`DateTime.parse` handles them correctly, and `DateTime.parse.to_time` results in the correct time.  `Time.parse` doesn't handle them correctly because `Time.zone_offset` uses a different regexp that only considers hours and minutes, not seconds.

Example:

~~~ruby
DateTime.parse("1200-02-15 BC 14:13:20-00:00:00").to_time
# => -1199-02-15 14:13:20 +0000
Time.parse("1200-02-15 BC 14:13:20-00:00:00")
# => -1199-02-15 14:13:20 -0752
Time.parse("1200-02-15 BC 14:13:20-00:00")
# => -1199-02-15 14:13:20 UTC
~~~

The attached patch fixes the issue by having the `Time.zone_offset` regexp respect seconds if they are present.

---Files--------------------------------
0001-Make-Time.parse-respect-timezone-offset-seconds.patch (1.8 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>