harvesthq/tzinfo — pull request #1 by bjhess (2013-10-08 03:03:28+00:00)
Title: tzdata2013d - O Jerusalem

_(Note: I'm not going to merge this with tzinfo/master. The useful comparison here is not this diff, but to the [v0.3.37 tag](https://github.com/harvesthq/tzinfo/compare/v0.3.37...tzcode2013d?expand=1). Also, I will probably follow up with a PR applying the [tzdata2013g updates](http://www.iana.org/time-zones). Just don't want to get too complicated.)_

Steps to update tzinfo 0.3.x line timezones:

1. Clone repository: https://github.com/tzinfo/tzinfo
2. Branch from the latest v0.3.x tag.
3. Download data set, in this case [tzdata2013d](http://mm.icann.org/pipermail/tz-announce/2013-July/000012.html).
4. Extract tzdata files.
5. From tzinfo clone repository root, parse data files from a command prompt:

```ruby
require File.join(File.dirname(__FILE__), "tzinfo", "lib", "tzinfo", "tzdataparser")
TZInfo::TZDataParser.new("/Users/barry/Sites/iridesco/tzinfo/tzdata2013d", "/Users/barry/Sites/iridesco/tzinfo/tzinfo/lib/tzinfo").execute
```

From here I "tested" things on the command line with this little script, modeled off some of the existing tests:

```ruby
require File.join(File.dirname(__FILE__), "tzinfo", "lib", "tzinfo")
include TZInfo

tz = Timezone.get('Asia/Jerusalem')

DateTime.new(2013,10,7,11,00,00) == tz.utc_to_local(DateTime.new(2013,10,7,8,00,00))
tz.period_for_utc(DateTime.new(2013,10,7,8,00,00)).zone_identifier
tz.period_for_utc(DateTime.new(2013,10,7,8,00,00)).utc_total_offset / 60 / 60

DateTime.new(2013,10,27,5,00,00) == tz.utc_to_local(DateTime.new(2013,10,27,3,00,00))
tz.period_for_utc(DateTime.new(2013,10,27,3,00,00)).zone_identifier
tz.period_for_utc(DateTime.new(2013,10,27,3,00,00)).utc_total_offset / 60 / 60
```

One trick was making sure the actual tzinfo gem wasn't loading. I had made the data file changes and was not seeing a difference until I blew away the gem and/or required things explicitly. Output:

```ruby
>> require File.join(File.dirname(__FILE__), "tzinfo", "lib", "tzinfo")
=> false
>> include TZInfo
=> Object
>>
?> tz = Timezone.get('Asia/Jerusalem')
=> #
>>
?> DateTime.new(2013,10,7,11,00,00) == tz.utc_to_local(DateTime.new(2013,10,7,8,00,00))
=> true
>> tz.period_for_utc(DateTime.new(2013,10,7,8,00,00)).zone_identifier
=> :IDT
>> tz.period_for_utc(DateTime.new(2013,10,7,8,00,00)).utc_total_offset / 60 / 60
=> 3
>>
?> DateTime.new(2013,10,27,5,00,00) == tz.utc_to_local(DateTime.new(2013,10,27,3,00,00))
=> true
>> tz.period_for_utc(DateTime.new(2013,10,27,3,00,00)).zone_identifier
=> :IST
>> tz.period_for_utc(DateTime.new(2013,10,27,3,00,00)).utc_total_offset / 60 / 60
=> 2
```

One sad thing when you look at the diff is that there are other changes beyond just this one. I'm somewhat comfortable with the risk. Once this is approved, then we can bring it into Harvest.