[#57574] [ruby-trunk - Feature #8976][Open] file-scope freeze_string directive — "akr (Akira Tanaka)" <akr@...>

70 messages 2013/10/02

[#57579] [ruby-trunk - Feature #8977][Open] String#frozen that takes advantage of the deduping — "sam.saffron (Sam Saffron)" <sam.saffron@...>

25 messages 2013/10/02

[#57679] [ruby-trunk - Feature #8987][Open] map/collect extension which handles arguments — "sowieso (So Wieso)" <sowieso@...>

16 messages 2013/10/05

[#57705] [ruby-trunk - Feature #8992][Open] Use String#freeze and compiler tricks to replace "str"f suffix — "headius (Charles Nutter)" <headius@...>

43 messages 2013/10/07

[#57727] [ruby-trunk - Feature #8998][Open] string keys for hash literals should use fstrings — "normalperson (Eric Wong)" <normalperson@...>

17 messages 2013/10/08

[#57771] [ruby-trunk - Bug #9008][Open] TestProcess#test_clock_getres_constants and TestProcess#test_clock_gettime_constants fails on ARM — "vo.x (Vit Ondruch)" <v.ondruch@...>

15 messages 2013/10/09

[#57888] [ruby-trunk - Feature #9025][Open] Clarify the error message when calling a method with the wrong number of arguments — Nerian (Gonzalo Rodríguez) <siotopo@...>

11 messages 2013/10/15

[#57993] [ruby-trunk - Feature #9047][Open] Alternate hash key syntax for symbols — "jamonholmgren (Jamon Holmgren)" <jamon@...>

13 messages 2013/10/23

[#58007] [ruby-trunk - Feature #9049][Open] Shorthands (a:b, *) for inclusive indexing — "mohawkjohn (John Woods)" <john.o.woods@...>

25 messages 2013/10/24

[#58033] [ruby-trunk - Bug #9053][Open] SSL Issue with Ruby 2.0.0 — "tisba (Sebastian Cohnen)" <ruby-lang@...>

16 messages 2013/10/25

[#58080] [ruby-trunk - Feature #9064][Open] Add support for packages, like in Java — "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>

23 messages 2013/10/30

[ruby-core:57693] [PATCH 0/2] Fix strptime '%s'

From: Felipe Contreras <felipe.contreras@...>
Date: 2013-10-07 01:13:40 UTC
List: ruby-core #57693
Hi,

There's multiple issues with the way '%s' is handled, starting with the less
controversial (%s):

  Time.strptime('0', '%s')
  => 1969-12-31 18:00:00 -0600
    
If '%s' is meant to imply UTC, then clearly there's a bug here.

After this patch series:
    
  Time.strptime('0', '%s')
  => 1970-01-01 00:00:00 +0000

However, the timezone can be overriden, and in other languages like C and Perl,
it's perfectly fine to use '%s %z'. In fact, Ruby already works fine with
'%s %z', for strftime:

  Time.at(0).localtime('+01:00').strftime('%s %z')
  => "0 +0100"

But it doesn't with strptime():

  Time.strptime('0 +0100', '%s %z').strftime('%s %z')
  => "0 -0600"

After this series:

  Time.strptime('0 +0100', '%s %z').strftime('%s %z')
  => "0 +0100"

The same happens with DateTime.

Rubinious has been fixed already:
https://github.com/rubysl/rubysl-time/commit/d0a613de9efd6092c04ab9eb5beba8bd13873726
https://github.com/rubysl/rubysl-date/commit/9d40977bdb00c58c4ec932bab4545b35bd728fde

Since the RubySpec standard library tests are moving towards the spec tests in
rubysl, Ruby is now failing these:

Time#strptime parses number of seconds since Unix Epoch as UTF FAILED
Expected -21600
 to equal 0

Time#strptime parses number of seconds since Unix Epoch with timezone FAILED
Expected "1969-12-31 18:00:00 -0600"
 to equal "1970-01-01 01:00:00 +0100"

DateTime#strptime parses seconds and timezone correctly FAILED
Expected "1970-01-01T00:00:00+00:00"
 to equal "1970-01-01T01:00:00+01:00"

So why not do the reasonable thing and apply these patches? Nobody woudld be
affected negatively, because not only will '%s' keep working as before, but it
would work better.

Charlie Somerville (1):
  datetime: fix strptime '%s %z'

Felipe Contreras (1):
  time: fix strptime '%s'

 ext/date/date_core.c            | 8 ++++++--
 lib/time.rb                     | 3 ++-
 test/date/test_date_strptime.rb | 6 ++++++
 test/test_time.rb               | 2 ++
 4 files changed, 16 insertions(+), 3 deletions(-)

-- 
1.8.4-fc

In This Thread

Prev Next