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

New Issue from (Jean F.) #8

Closed pavkam closed 5 years ago

pavkam commented 5 years ago

I'm working on the development of a software that uses the TZDB for Delphi to deal with the timezones' management, and I'd like to have your opinion about a problem that we are facing.

In a procedure, in order to decompose the periods of a timezone, we have to know the timezone's year of a UTC DateTime.

To do so, we are using these commands : thisBundledTimezone := TBundledTimeZone.GetTimeZone('America/Los_Angeles'); timeZoneYear := YearOf(IncMinute(aUTCDateTime, Round(thisBundledTimezone.UtcOffset.TotalMinutes)));

This is fine if the program is running on Windows, but it crashes on Linux.

The error occurs when we're trying to get the UtcOffset. The TBundledTimeZone can't read the FPeriods[I] in the function GetPeriodAndRule.

The thing is that FPeriods is a TList that is not typed (with TCompiledPeriod) and Delphi can't use it this way with Linux.

We can by the way see a warning when compiling a project that includes TZDB.pas, telling that TList is deprecated.

We have solved the problem by modifying the TZDB.pas unit, but that's quite a lot of changes in the declarations.

For your information, the Decomposer.pas unit doesn't have any problem with Linux because it is already working with typed TLists (function Decompose).

pavkam commented 5 years ago

@mbtaylor1982 wasn't the other fixes supposed to fix something like this?

mbtaylor1982 commented 5 years ago

@pavkam Are you referring to issue 5 raised by @ccy. if so i think it may be similar. perhaps we need an ifdef for linux.

pavkam commented 5 years ago

@mbtaylor1982 -- yeah. I think so.

I will try to look at it next week (I think there's a Delphi community edition).

mbtaylor1982 commented 5 years ago

Yeah I’ll be moving to the community edition too as I’m changing jobs and won’t have access to full versions of Delphi for much longer.

jeanfrauc commented 5 years ago

Hi, I have some good news : I am now using the new Delphi 10.3 Rio to compile my project and the problem with TZDB.pas on Linux has disappeared! They probably have changed their way to deal with the untyped TList. My program is now working fine on Windows and Linux.

mbtaylor1982 commented 5 years ago

Thanks for letting us know however I will look into it when I get time,

pavkam commented 5 years ago

Closing as it doesn't appear to be an issue anymore.