tzinfo 0.3.28 → 0.3.29

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tzinfo might be problematic. Click here for more details.

@@ -77,86 +77,7 @@ module TZInfo
77
77
  tz.transition 2009, 10, :o7, 1256425200
78
78
  tz.transition 2010, 3, :o6, 1269730800
79
79
  tz.transition 2010, 10, :o7, 1288479600
80
- tz.transition 2011, 3, :o6, 1301180400
81
- tz.transition 2011, 10, :o7, 1319929200
82
- tz.transition 2012, 3, :o6, 1332630000
83
- tz.transition 2012, 10, :o7, 1351378800
84
- tz.transition 2013, 3, :o6, 1364684400
85
- tz.transition 2013, 10, :o7, 1382828400
86
- tz.transition 2014, 3, :o6, 1396134000
87
- tz.transition 2014, 10, :o7, 1414278000
88
- tz.transition 2015, 3, :o6, 1427583600
89
- tz.transition 2015, 10, :o7, 1445727600
90
- tz.transition 2016, 3, :o6, 1459033200
91
- tz.transition 2016, 10, :o7, 1477782000
92
- tz.transition 2017, 3, :o6, 1490482800
93
- tz.transition 2017, 10, :o7, 1509231600
94
- tz.transition 2018, 3, :o6, 1521932400
95
- tz.transition 2018, 10, :o7, 1540681200
96
- tz.transition 2019, 3, :o6, 1553986800
97
- tz.transition 2019, 10, :o7, 1572130800
98
- tz.transition 2020, 3, :o6, 1585436400
99
- tz.transition 2020, 10, :o7, 1603580400
100
- tz.transition 2021, 3, :o6, 1616886000
101
- tz.transition 2021, 10, :o7, 1635634800
102
- tz.transition 2022, 3, :o6, 1648335600
103
- tz.transition 2022, 10, :o7, 1667084400
104
- tz.transition 2023, 3, :o6, 1679785200
105
- tz.transition 2023, 10, :o7, 1698534000
106
- tz.transition 2024, 3, :o6, 1711839600
107
- tz.transition 2024, 10, :o7, 1729983600
108
- tz.transition 2025, 3, :o6, 1743289200
109
- tz.transition 2025, 10, :o7, 1761433200
110
- tz.transition 2026, 3, :o6, 1774738800
111
- tz.transition 2026, 10, :o7, 1792882800
112
- tz.transition 2027, 3, :o6, 1806188400
113
- tz.transition 2027, 10, :o7, 1824937200
114
- tz.transition 2028, 3, :o6, 1837638000
115
- tz.transition 2028, 10, :o7, 1856386800
116
- tz.transition 2029, 3, :o6, 1869087600
117
- tz.transition 2029, 10, :o7, 1887836400
118
- tz.transition 2030, 3, :o6, 1901142000
119
- tz.transition 2030, 10, :o7, 1919286000
120
- tz.transition 2031, 3, :o6, 1932591600
121
- tz.transition 2031, 10, :o7, 1950735600
122
- tz.transition 2032, 3, :o6, 1964041200
123
- tz.transition 2032, 10, :o7, 1982790000
124
- tz.transition 2033, 3, :o6, 1995490800
125
- tz.transition 2033, 10, :o7, 2014239600
126
- tz.transition 2034, 3, :o6, 2026940400
127
- tz.transition 2034, 10, :o7, 2045689200
128
- tz.transition 2035, 3, :o6, 2058390000
129
- tz.transition 2035, 10, :o7, 2077138800
130
- tz.transition 2036, 3, :o6, 2090444400
131
- tz.transition 2036, 10, :o7, 2108588400
132
- tz.transition 2037, 3, :o6, 2121894000
133
- tz.transition 2037, 10, :o7, 2140038000
134
- tz.transition 2038, 3, :o6, 59172251, 24
135
- tz.transition 2038, 10, :o7, 59177459, 24
136
- tz.transition 2039, 3, :o6, 59180987, 24
137
- tz.transition 2039, 10, :o7, 59186195, 24
138
- tz.transition 2040, 3, :o6, 59189723, 24
139
- tz.transition 2040, 10, :o7, 59194931, 24
140
- tz.transition 2041, 3, :o6, 59198627, 24
141
- tz.transition 2041, 10, :o7, 59203667, 24
142
- tz.transition 2042, 3, :o6, 59207363, 24
143
- tz.transition 2042, 10, :o7, 59212403, 24
144
- tz.transition 2043, 3, :o6, 59216099, 24
145
- tz.transition 2043, 10, :o7, 59221139, 24
146
- tz.transition 2044, 3, :o6, 59224835, 24
147
- tz.transition 2044, 10, :o7, 59230043, 24
148
- tz.transition 2045, 3, :o6, 59233571, 24
149
- tz.transition 2045, 10, :o7, 59238779, 24
150
- tz.transition 2046, 3, :o6, 59242307, 24
151
- tz.transition 2046, 10, :o7, 59247515, 24
152
- tz.transition 2047, 3, :o6, 59251211, 24
153
- tz.transition 2047, 10, :o7, 59256251, 24
154
- tz.transition 2048, 3, :o6, 59259947, 24
155
- tz.transition 2048, 10, :o7, 59264987, 24
156
- tz.transition 2049, 3, :o6, 59268683, 24
157
- tz.transition 2049, 10, :o7, 59273891, 24
158
- tz.transition 2050, 3, :o6, 59277419, 24
159
- tz.transition 2050, 10, :o7, 59282627, 24
80
+ tz.transition 2011, 3, :o4, 1301180400
160
81
  end
161
82
  end
162
83
  end
@@ -24,9 +24,6 @@ module TZInfo
24
24
  country 'AM', 'Armenia' do |c|
25
25
  c.timezone 'Asia/Yerevan', 2411, 60, 89, 2
26
26
  end
27
- country 'AN', 'Netherlands Antilles' do |c|
28
- c.timezone 'America/Curacao', 731, 60, -69, 1
29
- end
30
27
  country 'AO', 'Angola' do |c|
31
28
  c.timezone 'Africa/Luanda', -44, 5, 397, 30
32
29
  end
@@ -125,6 +122,9 @@ module TZInfo
125
122
  country 'BO', 'Bolivia' do |c|
126
123
  c.timezone 'America/La_Paz', -33, 2, -1363, 20
127
124
  end
125
+ country 'BQ', 'Bonaire Sint Eustatius & Saba' do |c|
126
+ c.timezone 'America/Kralendijk', 14581, 1200, -20483, 300
127
+ end
128
128
  country 'BR', 'Brazil' do |c|
129
129
  c.timezone 'America/Noronha', -77, 20, -389, 12, 'Atlantic islands'
130
130
  c.timezone 'America/Belem', -29, 20, -2909, 60, 'Amapa, E Para'
@@ -236,6 +236,9 @@ module TZInfo
236
236
  country 'CV', 'Cape Verde' do |c|
237
237
  c.timezone 'Atlantic/Cape_Verde', 179, 12, -1411, 60
238
238
  end
239
+ country 'CW', 'Curacao' do |c|
240
+ c.timezone 'America/Curacao', 731, 60, -69, 1
241
+ end
239
242
  country 'CX', 'Christmas Island' do |c|
240
243
  c.timezone 'Indian/Christmas', -125, 12, 6343, 60
241
244
  end
@@ -754,6 +757,9 @@ module TZInfo
754
757
  country 'SV', 'El Salvador' do |c|
755
758
  c.timezone 'America/El_Salvador', 137, 10, -446, 5
756
759
  end
760
+ country 'SX', 'Sint Maarten' do |c|
761
+ c.timezone 'America/Lower_Princes', 12997, 720, -22697, 360
762
+ end
757
763
  country 'SY', 'Syria' do |c|
758
764
  c.timezone 'Asia/Damascus', 67, 2, 363, 10
759
765
  end
@@ -143,10 +143,12 @@ module TZInfo
143
143
  timezone 'America/Kentucky/Louisville'
144
144
  timezone 'America/Kentucky/Monticello'
145
145
  linked_timezone 'America/Knox_IN'
146
+ linked_timezone 'America/Kralendijk'
146
147
  timezone 'America/La_Paz'
147
148
  timezone 'America/Lima'
148
149
  timezone 'America/Los_Angeles'
149
150
  linked_timezone 'America/Louisville'
151
+ linked_timezone 'America/Lower_Princes'
150
152
  timezone 'America/Maceio'
151
153
  timezone 'America/Managua'
152
154
  timezone 'America/Manaus'
@@ -68,6 +68,26 @@ module TZInfo
68
68
  # Whether the timezones index has been loaded yet.
69
69
  @@index_loaded = false
70
70
 
71
+ # Default value of the dst parameter of the local_to_utc and
72
+ # period_for_local methods.
73
+ @@default_dst = nil
74
+
75
+ # Sets the default value of the optional dst parameter of the
76
+ # local_to_utc and period_for_local methods. Can be set to nil, true or
77
+ # false.
78
+ #
79
+ # The value of default_dst defaults to nil if unset.
80
+ def self.default_dst=(value)
81
+ @@default_dst = value.nil? ? nil : !!value
82
+ end
83
+
84
+ # Gets the default value of the optional dst parameter of the
85
+ # local_to_utc and period_for_local methods. Can be set to nil, true or
86
+ # false.
87
+ def self.default_dst
88
+ @@default_dst
89
+ end
90
+
71
91
  # Returns a timezone by its identifier (e.g. "Europe/London",
72
92
  # "America/Chicago" or "UTC").
73
93
  #
@@ -328,7 +348,12 @@ module TZInfo
328
348
  # array of the periods that need to be resolved. The block can select and
329
349
  # return a single period or return nil or an empty array
330
350
  # to cause an AmbiguousTime exception to be raised.
331
- def period_for_local(local, dst = nil)
351
+ #
352
+ # The default value of the dst parameter can be specified by setting
353
+ # Timezone.default_dst. If default_dst is not set, or is set to nil, then
354
+ # an AmbiguousTime exception will be raised in ambiguous situations unless
355
+ # a block is given to resolve the ambiguity.
356
+ def period_for_local(local, dst = Timezone.default_dst)
332
357
  results = periods_for_local(local)
333
358
 
334
359
  if results.empty?
@@ -406,7 +431,12 @@ module TZInfo
406
431
  # array of the periods that need to be resolved. The block can return a
407
432
  # single period to use to convert the time or return nil or an empty array
408
433
  # to cause an AmbiguousTime exception to be raised.
409
- def local_to_utc(local, dst = nil)
434
+ #
435
+ # The default value of the dst parameter can be specified by setting
436
+ # Timezone.default_dst. If default_dst is not set, or is set to nil, then
437
+ # an AmbiguousTime exception will be raised in ambiguous situations unless
438
+ # a block is given to resolve the ambiguity.
439
+ def local_to_utc(local, dst = Timezone.default_dst)
410
440
  TimeOrDateTime.wrap(local) {|wrapped|
411
441
  if block_given?
412
442
  period = period_for_local(wrapped, dst) {|periods| yield periods }
data/test/tc_timezone.rb CHANGED
@@ -42,6 +42,29 @@ class TCTimezone < Test::Unit::TestCase
42
42
  end
43
43
  end
44
44
 
45
+ def setup
46
+ @orig_default_dst = Timezone.default_dst
47
+ end
48
+
49
+ def teardown
50
+ Timezone.default_dst = @orig_default_dst
51
+ end
52
+
53
+ def test_default_dst_initial_value
54
+ assert_nil(Timezone.default_dst)
55
+ end
56
+
57
+ def test_set_default_dst
58
+ Timezone.default_dst = true
59
+ assert_equal(true, Timezone.default_dst)
60
+ Timezone.default_dst = false
61
+ assert_equal(false, Timezone.default_dst)
62
+ Timezone.default_dst = nil
63
+ assert_nil(Timezone.default_dst)
64
+ Timezone.default_dst = 0
65
+ assert_equal(true, Timezone.default_dst)
66
+ end
67
+
45
68
  def test_get_valid_1
46
69
  tz = Timezone.get('Europe/London')
47
70
 
@@ -383,6 +406,52 @@ class TCTimezone < Test::Unit::TestCase
383
406
  assert_raises(PeriodNotFound) { i_tz.period_for_local(i) }
384
407
  end
385
408
 
409
+ def test_period_for_local_default_dst_set_true
410
+ Timezone.default_dst = true
411
+
412
+ o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
413
+ o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
414
+
415
+ t1 = TimezoneTransitionInfo.new(o2, o1, 1081062000)
416
+ t2 = TimezoneTransitionInfo.new(o1, o2, 1099202400)
417
+ t3 = TimezoneTransitionInfo.new(o2, o1, 1112511600)
418
+
419
+ p1 = TimezonePeriod.new(t1, t2)
420
+ p2 = TimezonePeriod.new(t2, t3)
421
+
422
+ dt = DateTime.new(2004,10,31,1,30,0)
423
+
424
+ tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
425
+
426
+ assert_equal(p1, tz.period_for_local(dt))
427
+ assert_equal(p1, tz.period_for_local(dt, true))
428
+ assert_equal(p2, tz.period_for_local(dt, false))
429
+ assert_raises(AmbiguousTime) { tz.period_for_local(dt, nil) }
430
+ end
431
+
432
+ def test_period_for_local_default_dst_set_false
433
+ Timezone.default_dst = false
434
+
435
+ o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
436
+ o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
437
+
438
+ t1 = TimezoneTransitionInfo.new(o2, o1, 1081062000)
439
+ t2 = TimezoneTransitionInfo.new(o1, o2, 1099202400)
440
+ t3 = TimezoneTransitionInfo.new(o2, o1, 1112511600)
441
+
442
+ p1 = TimezonePeriod.new(t1, t2)
443
+ p2 = TimezonePeriod.new(t2, t3)
444
+
445
+ dt = DateTime.new(2004,10,31,1,30,0)
446
+
447
+ tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
448
+
449
+ assert_equal(p2, tz.period_for_local(dt))
450
+ assert_equal(p1, tz.period_for_local(dt, true))
451
+ assert_equal(p2, tz.period_for_local(dt, false))
452
+ assert_raises(AmbiguousTime) { tz.period_for_local(dt, nil) }
453
+ end
454
+
386
455
  def test_period_for_local_dst_flag_resolved
387
456
  o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
388
457
  o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
@@ -648,6 +717,52 @@ class TCTimezone < Test::Unit::TestCase
648
717
  assert_raises(PeriodNotFound) { i_tz.local_to_utc(i) }
649
718
  end
650
719
 
720
+ def test_local_to_utc_default_dst_set_true
721
+ Timezone.default_dst = true
722
+
723
+ o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
724
+ o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
725
+
726
+ t1 = TimezoneTransitionInfo.new(o2, o1, 1081062000)
727
+ t2 = TimezoneTransitionInfo.new(o1, o2, 1099202400)
728
+ t3 = TimezoneTransitionInfo.new(o2, o1, 1112511600)
729
+
730
+ p1 = TimezonePeriod.new(t1, t2)
731
+ p2 = TimezonePeriod.new(t2, t3)
732
+
733
+ dt = DateTime.new(2004,10,31,1,30,0)
734
+ tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
735
+
736
+ assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt))
737
+ assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true))
738
+ assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false))
739
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt, nil) }
740
+ assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt) {|periods| raise BlockCalled, 'should not be called' })
741
+ end
742
+
743
+ def test_local_to_utc_default_dst_set_false
744
+ Timezone.default_dst = false
745
+
746
+ o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
747
+ o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
748
+
749
+ t1 = TimezoneTransitionInfo.new(o2, o1, 1081062000)
750
+ t2 = TimezoneTransitionInfo.new(o1, o2, 1099202400)
751
+ t3 = TimezoneTransitionInfo.new(o2, o1, 1112511600)
752
+
753
+ p1 = TimezonePeriod.new(t1, t2)
754
+ p2 = TimezonePeriod.new(t2, t3)
755
+
756
+ dt = DateTime.new(2004,10,31,1,30,0)
757
+ tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt)
758
+
759
+ assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt))
760
+ assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false))
761
+ assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true))
762
+ assert_raises(AmbiguousTime) { tz.local_to_utc(dt, nil) }
763
+ assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt) {|periods| raise BlockCalled, 'should not be called' })
764
+ end
765
+
651
766
  def test_local_to_utc_dst_flag_resolved
652
767
  o1 = TimezoneOffsetInfo.new(-18000, 0, :EST)
653
768
  o2 = TimezoneOffsetInfo.new(-18000, 3600, :EDT)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 28
10
- version: 0.3.28
9
+ - 29
10
+ version: 0.3.29
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip Ross
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-12 16:00:00 -07:00
18
+ date: 2011-06-26 16:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -464,6 +464,8 @@ files:
464
464
  - lib/tzinfo/definitions/America/Matamoros.rb
465
465
  - lib/tzinfo/definitions/America/Bahia_Banderas.rb
466
466
  - lib/tzinfo/definitions/America/Metlakatla.rb
467
+ - lib/tzinfo/definitions/America/Lower_Princes.rb
468
+ - lib/tzinfo/definitions/America/Kralendijk.rb
467
469
  - lib/tzinfo/definitions/Arctic/Longyearbyen.rb
468
470
  - lib/tzinfo/definitions/Antarctica/DumontDUrville.rb
469
471
  - lib/tzinfo/definitions/Antarctica/Palmer.rb