From: Felipe Contreras Date: 2013-10-07T13:32:29-05:00 Subject: [ruby-core:57711] Re: [PATCH 1/2] time: fix strptime '%s' On Mon, Oct 7, 2013 at 10:17 AM, Tanaka Akira wrote: > 2013/10/7 Felipe Contreras : >> '%s' is meant to imply UTC, however: >> >> Time.strptime('0', '%s') >> => 1969-12-31 18:00:00 -0600 >> >> After this patch: >> >> Time.strptime('0', '%s') >> => 1970-01-01 00:00:00 +0000 > It seems the patch changes the behavior of Time.strptime("0", "%s"). That's what it says right above in the explanation ^. > before the patch: > % ruby -rtime -e 'p Time.strptime("0", "%s")' > 1970-01-01 09:00:00 +0900 > > after the patch: > % ./ruby -rtime -e 'p Time.strptime("0", "%s")' > 1970-01-01 00:00:00 +0000 > > Is there a reason for that? As it says on the explanation above: '%s' is meant to imply UTC. However, I just read the man pages again: strptime(3): %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). Leap seconds are not counted unless leap second support is available. strftime(3): %s The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). (TZ) It doesn't really say '%s' is UTC, but that it's the seconds since the Epoch (which is UTC). In C strptime('0', '%s') is returning a local timezone, so perhaps my patch is wrong in changing that, but strptime('0 +0100', '%s %z') still needs to be fixed. Cheers. -- Felipe Contreras