Issue #7445 has been updated by felipec (Felipe Contreras).


tadf (tadayoshi funaba) wrote:
> but you can't preserve offset with mktime(3).

We are not talking about mktime(3), we are talking about strptime(). This is a red herring argument.

The documentation of Date.strptime() clearly mentions C's strptime(3) and strftime:

"See also strptime(3) and strftime."

And both of them work perfectly fine with '%s %z'. I showed in the code above how C's strptime works with '%s %z', and here I'm showing Ruby's strftime does as well:

  require 'date'
  d = DateTime.new(1970,1,1,1,0,0,'+01:00')
  d.strftime('%s %z')
  => "0 +0100"

So both strptime(3) and DateTime.strftime() accept '%s %z', and Charlie Somerville attached a patch that can be applied on top of Ruby's trunk, and DateTime.strptime() would work just like strptime(3), and would be consistent with DateTime.strftime().

What reason could you possibly have to not accept this patch? What use-case would it break? How could it possibly affect negatively anybody?

If you truly think '%s %z' does not make sense, then throw an error when both %s and %z are used at the same time, both in DateTime.strptime(), DateTime._strptime(), and DateTime.strftime(). Also, update the documentation to mention that it's not exactly the same as strptime(3), and neither strftime(3). This of course would be totally stupid.

Just accept the patch and everything will be consistent.

> if you want substring which denote %z, you can call _strptime.

No, I want strptime to work correctly.

> you told about C's stdlib.
> why not talk about ruby's Time?
> Time is based on stdlib.
> why not want it with Time?

That English does not parse.
----------------------------------------
Bug #7445: strptime('%s %z') doesn't work
https://bugs.ruby-lang.org/issues/7445#change-41597

Author: felipec (Felipe Contreras)
Status: Rejected
Priority: Low
Assignee: tadf (tadayoshi funaba)
Category: lib
Target version: Next Major
ruby -v: ruby 1.9.3p327
Backport: 


See:

    ruby -e "require 'date'; p DateTime.strptime('0 +0100', '%s %z').strftime('%s %z')"

The timezone is ignored.


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