Changeset 9206 for plugins/tzinfo_timezone
- Timestamp:
- 04/01/08 23:25:03 (5 months ago)
- Files:
-
- plugins/tzinfo_timezone/lib/tzinfo_timezone.rb (modified) (1 diff)
- plugins/tzinfo_timezone/test/tzinfo_timezone_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/tzinfo_timezone/lib/tzinfo_timezone.rb
r6093 r9206 179 179 tzinfo.now 180 180 end 181 182 # Returns the UTC offset of this time zone adjusted for DST at the 183 # current time, or optionally at the time specified by +relative_to+. 184 def dst_utc_offset(relative_to = now) 185 dst_offset = tzinfo.period_for_local(relative_to, true).dst? ? 3600 : 0 186 utc_offset + dst_offset 187 end 181 188 182 189 # Return the current date in this time zone. plugins/tzinfo_timezone/test/tzinfo_timezone_test.rb
r4105 r9206 21 21 end 22 22 end 23 24 def test_dst_utc_offset_in_standard_time 25 zone = TzinfoTimezone["Central Time (US & Canada)"] 26 time = Time.utc(2008, 3, 9) 27 assert_equal zone.utc_offset, zone.dst_utc_offset(time) 28 end 29 30 def test_dst_utc_offset_in_daylight_time 31 zone = TzinfoTimezone["Central Time (US & Canada)"] 32 time = Time.utc(2008, 3, 9, 12) 33 assert_equal zone.utc_offset + 3600, zone.dst_utc_offset(time) 34 end 23 35 end