pavkam / tzdb

Delphi/FPC Time Zone Database
https://www.iana.org/time-zones
BSD 3-Clause "New" or "Revised" License
84 stars 27 forks source link

I needed to convert some date times to one timezone to another, and I found your TZDB project. #40

Open pavkam opened 2 years ago

pavkam commented 2 years ago

I needed to convert some date times to one timezone to another, and I found your TZDB project.

It works like a charm, so It have saved me a lot of time. Many thanks 😊

But I’m missing one thing. I have tried to implement what I need, inheriting my own class from TBundledTimeZone, but all the data I need is Private or under the implementation section, so I can’t access it without modifying the original sources.

What I am missing is a function to get the year/date when a Standard or Daylight rule start for a given year.

Let me explain… I have seen that the function DaylightTimeStart(Year) returns the day and time of the Daylight segment for the given year, but I need to know when the rule applied to get that Daylight segment started to be applied.

Browsing TZDB.pas, I have seen that that info is in CFamily_X_Arr:

{ Date-bound rules for EU family }

CFamily_1_Arr: array[0 .. 5] of TYearBoundRule = (

(FStart: 1977; FEnd: 1980; FRule: @CRules[50]),

(FStart: 1977; FEnd: 1977; FRule: @CRules[51]),

(FStart: 1978; FEnd: 1978; FRule: @CRules[52]),

(FStart: 1979; FEnd: 1995; FRule: @CRules[51]),

(FStart: 1981; FEnd: 9999; FRule: @CRules[53]),

(FStart: 1996; FEnd: 9999; FRule: @CRules[54])

);

This info is important to properly define a timezone in a iCalendar (.ics) file.

Would it be possible to include the function I need (something like DaylightRuleStartYear/Date - StandardRuleStartYear/Date) in next distributions?

I think it could be helpful for many people too.

pavkam commented 2 years ago

This is outside my scope at the moment. But may look at it in the future.