[前][次][番号順一覧][スレッド一覧]

ruby-changes:36477

From: nobu <ko1@a...>
Date: Tue, 25 Nov 2014 15:26:39 +0900 (JST)
Subject: [ruby-changes:36477] nobu:r48559 (trunk): vcs.rb: make Time with proper offset

nobu	2014-11-25 15:26:26 +0900 (Tue, 25 Nov 2014)

  New Revision: 48559

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48559

  Log:
    vcs.rb: make Time with proper offset
    
    * tool/vcs.rb (get_revisions): use Time.new instead of Time.mktime
      which does not accept UTC offset, and offset manually for older
      versions than 1.9.

  Modified files:
    trunk/ChangeLog
    trunk/tool/vcs.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48558)
+++ ChangeLog	(revision 48559)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 25 15:26:33 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* tool/vcs.rb (get_revisions): use Time.new instead of Time.mktime
+	  which does not accept UTC offset, and offset manually for older
+	  versions than 1.9.
+
 Tue Nov 25 12:14:43 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* process.c (Init_process): initialize static IDs before constant
Index: tool/vcs.rb
===================================================================
--- tool/vcs.rb	(revision 48558)
+++ tool/vcs.rb	(revision 48559)
@@ -62,7 +62,11 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L62
     if modified
       /\A(\d+)-(\d+)-(\d+)\D(\d+):(\d+):(\d+(?:\.\d+)?)\s*(?:Z|([-+]\d\d)(\d\d))\z/ =~ modified or
         raise "unknown time format - #{modified}"
-      modified = Time.mktime(*($~[1..6] + [$7 ? "#{$7}:#{$8}" : "+00:00"]))
+      begin
+        modified = Time.new(*$~[1..6].map(&:to_i), ($7 ? "#{$7}:#{$8}" : "+00:00"))
+      rescue ArgumentError
+        modified = Time.utc(*$~[1..6]) + $7.to_i * 3600 + $8.to_i * 60
+      end
     end
     return last, changed, modified, *rest
   end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]