summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-04 11:52:26 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-04 11:52:26 +0000
commitfffbcf286762b9f78dec19c59aaa8ce0babb5551 (patch)
treefc2b4a32c1fb84a5825002daf10e433dd36acc86
parenta18177d5ed270ba7007c12011b9693ec226b1ad6 (diff)
* lib/time.rb (Time.force_zone!): Use usual local time if it has
expected offset from UTC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--NEWS5
-rw-r--r--lib/time.rb5
3 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 9c0c112d9a..cad4cff7ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun May 4 20:51:32 2014 Tanaka Akira <akr@fsij.org>
+
+ * lib/time.rb (Time.force_zone!): Use usual local time if it has
+ expected offset from UTC.
+
Sun May 4 17:58:12 2014 Tanaka Akira <akr@fsij.org>
* lib/time.rb (Time.force_zone!): New private method.
diff --git a/NEWS b/NEWS
index 06b265a45b..97b56e9174 100644
--- a/NEWS
+++ b/NEWS
@@ -73,8 +73,9 @@ with all sufficient information, see the ChangeLog file.
=== Stdlib compatibility issues (excluding feature bug fixes)
* time.rb
- * Time.parse, Time.strptime, Time.rfc2822, Time.xmlschema produces
- fixed-offset Time objects to preserve the offset from UTC.
+ * Time.parse, Time.strptime, Time.rfc2822, Time.xmlschema may produce
+ fixed-offset Time objects.
+ It is happen when usual localtime doesn't preserve the offset from UTC.
* Time.httpdate produces always UTC Time object.
=== Built-in global variables compatibility issues
diff --git a/lib/time.rb b/lib/time.rb
index e394078a03..f080718dff 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -178,7 +178,10 @@ class Time
if zone_utc?(zone)
t.utc
elsif offset ||= zone_offset(zone)
- t.localtime(offset)
+ t.localtime
+ if t.utc_offset != offset
+ t.localtime(offset)
+ end
else
t.localtime
end