Skip to content

Commit

Permalink
Daylight Savings Time
Browse files Browse the repository at this point in the history
  • Loading branch information
cbandy committed Apr 10, 2014
1 parent 93018e2 commit 8009b16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/icu/calendar.rb
Expand Up @@ -72,6 +72,12 @@ def timezones
end
end

def daylight_time?
Library.assert_success do |status|
Library.ucal_inDaylightTime(@calendar, status)
end
end

def initialize(timezone = nil, locale = nil)
calendar = wchar_buffer_from_string_or_nil(timezone) do |timezone|
Library.assert_success do |status|
Expand Down
14 changes: 14 additions & 0 deletions spec/icu/calendar_spec.rb
Expand Up @@ -168,6 +168,20 @@ def icu_version_at_least(version)
end
end

describe '#daylight_time?' do
subject(:calendar) { Calendar.new('US/Central') }

specify do
calendar.time = Time.new(2010, 5, 8)
expect(calendar).to be_daylight_time
end

specify do
calendar.time = Time.new(2012, 11, 15)
expect(calendar).to_not be_daylight_time
end
end

describe '#locale' do
it 'returns the locale' do
expect(Calendar.new(nil, 'en_US').locale).to eq('en_US')
Expand Down

0 comments on commit 8009b16

Please sign in to comment.