Timezone conversion

This forum is for general developer support questions.
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Timezone conversion

Post by abalaban »

Is there a way to easily convert a (past) datetime value given in one timezone into another one?
Typically I'm receiving a string like "2014-10-18T10:05:10Z" and I would like to know what date and time it was using Paris timezone.
I'm able to parse the datetime value without problem but I'm stuck with the timezone conversion (nothing seems to be provided in timezone library where such function should reside IMHO).
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
tboeckel
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 68
Joined: Mon Jun 20, 2011 8:56 am
Contact:

Re: Timezone conversion

Post by tboeckel »

Unfortunately there is no function (yet) in AmigaOS for this task. This is why YAM is using libtz to do the necessary conversion and to decide wether the given date/time was within DST or not. timezone.library can tell you if DST is active now, but not for an arbitrary date/time in the past or in the future. This is definitely something that needs to be added.
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Timezone conversion

Post by abalaban »

Is binary port of libtz publically available somewhere?
I agree this is something that would be nice to address in the future. timezone.library autodoc currently seems to have plenty of room for such a thing ;)
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
tboeckel
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 68
Joined: Mon Jun 20, 2011 8:56 am
Contact:

Re: Timezone conversion

Post by tboeckel »

abalaban wrote:Is binary port of libtz publically available somewhere?
I doubt it. At least for YAM we are building libtz from scratch. It is only a very few files:
libtz in YAM

And it requires the zoneinfo files for all the different locations on earth, each with its specific rules when DST was active in the the past.
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Timezone conversion

Post by nbache »

tboeckel wrote:And it requires the zoneinfo files for all the different locations on earth, each with its specific rules when DST was active in the the past.
Timezone.library already comes with the .timezone files (XML-based) which are installed in Locale:Timezones. Would it be possible/preferable to base any solution on those instead, so as not to need two different sets of files with (I assume) more or less the same info?

Best regards,

Niels
User avatar
abalaban
Beta Tester
Beta Tester
Posts: 456
Joined: Mon Dec 20, 2010 2:09 pm
Location: France
Contact:

Re: Timezone conversion

Post by abalaban »

No I doubt it because files used by libtz seems to be binaries while files from the timezone.library are (proprietary) xml files. I guess the only solution is to add such feature (convert an arbitrary date from a specified TZ to another one) to the timezone.library.
AmigaOne X1000 running AOS 4 beta
AmigaOne XE/G4
Amiga 1200/PPC 603e + BVision PPC
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Timezone conversion

Post by nbache »

abalaban wrote:I guess the only solution is to add such feature (convert an arbitrary date from a specified TZ to another one) to the timezone.library.
Yes, that was one of the solutions I hoped for to avoid duplicating the info in two types of files ;-). That would be perfect, IMHO.

Best regards,

Niels
xenic
Posts: 1185
Joined: Sun Jun 19, 2011 12:06 am

Re: Timezone conversion

Post by xenic »

nbache wrote:
abalaban wrote:I guess the only solution is to add such feature (convert an arbitrary date from a specified TZ to another one) to the timezone.library.
Yes, that was one of the solutions I hoped for to avoid duplicating the info in two types of files ;-). That would be perfect, IMHO.
I think the timezone files in Locale/Timezones only contain current timezone data (change dates for DST). We would need the historical timezone data to account for changes in the DST dates. For example, the DST (daylight saving time) change dates in the U.S. were changed several years ago. Any calculations based on the current DST dates would be incorrect for dates preceeding those changes.
AmigaOne X1000 with 2GB memory - OS4.1 FE
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 530
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Timezone conversion

Post by salass00 »

xenic wrote: I think the timezone files in Locale/Timezones only contain current timezone data (change dates for DST). We would need the historical timezone data to account for changes in the DST dates. For example, the DST (daylight saving time) change dates in the U.S. were changed several years ago. Any calculations based on the current DST dates would be incorrect for dates preceeding those changes.
How many years would those "several years ago" be exactly?

If the change was made before the AmigaOS epoch (1.1.1978) then there isn't really any need to worry about it...
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Timezone conversion

Post by nbache »

salass00 wrote:
xenic wrote:I think the timezone files in Locale/Timezones only contain current timezone data (change dates for DST). We would need the historical timezone data to account for changes in the DST dates.
Right, of course. So, if these data are part of the zoneinfo files, maybe it would be wiser to make timezone.library ale to use thos instead of the ons it uses now.
For example, the DST (daylight saving time) change dates in the U.S. were changed several years ago. Any calculations based on the current DST dates would be incorrect for dates preceeding those changes.
How many years would those "several years ago" be exactly?

If the change was made before the AmigaOS epoch (1.1.1978) then there isn't really any need to worry about it...
No, there have been several changes, the latest in 2007:

http://en.wikipedia.org/wiki/History_of ... light_Time

And other places in the world have made changes as well within the Amiga epoch.

Best regards,

Niels
Post Reply