aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-03-28 04:06:47 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-03-28 04:06:47 +0000
commit59183eec6f8d3e5d1ac5046dbd4f5cefc7041256 (patch)
tree223e06207adb97a74ebd84e43aee4c9b7c50a2af /activesupport/lib/active_support/values
parent129d94477b1bb4478d1d8ceaed2a0f9a615e2d23 (diff)
downloadrails-59183eec6f8d3e5d1ac5046dbd4f5cefc7041256.tar.gz
rails-59183eec6f8d3e5d1ac5046dbd4f5cefc7041256.tar.bz2
rails-59183eec6f8d3e5d1ac5046dbd4f5cefc7041256.zip
Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9107 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/values')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 91f0394472..9b9602432c 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -145,15 +145,20 @@ class TimeZone
}
include Comparable
- attr_reader :name, :utc_offset
+ attr_reader :name
# Create a new TimeZone object with the given name and offset. The
# offset is the number of seconds that this time zone is offset from UTC
# (GMT). Seconds were chosen as the offset unit because that is the unit that
# Ruby uses to represent time zone offsets (see Time#utc_offset).
- def initialize(name, utc_offset)
+ def initialize(name, utc_offset, tzinfo = nil)
@name = name
@utc_offset = utc_offset
+ @tzinfo = tzinfo
+ end
+
+ def utc_offset
+ @utc_offset ||= tzinfo.current_period.utc_offset
end
# Returns the offset of this time zone as a formatted string, of the