kaitai_struct_formats icon indicating copy to clipboard operation
kaitai_struct_formats copied to clipboard

Add Time Zone Information Format (TZif) - common/tzif.ksy

Open ian-abbott opened this issue 3 years ago • 5 comments

TZif files are commonly used by the C standard libraries on most UNIX systems to calculate local time from universal time for a time zone, or (with some amount of ambiguity for negative transitions) vice versa.

ian-abbott avatar Mar 09 '21 14:03 ian-abbott

I have combined previous commits into a single commit and rebased onto the master branch. I had to use a slightly ugly workaround in the repeat-expr values for the tz_data.transition_times and tz_data.transition_types arrays. These arrays are the same length so I used the same parameter, but compiler version 0.10 warned about the name of the identifier num_transitions used for the repeat count. It wanted me to rename it to both num_transition_times and num_transition_types. I worked around it by using num_transitions + 0.

ian-abbott avatar Apr 05 '23 13:04 ian-abbott

I guess it was just a warning, not an error.

KOLANICH avatar Apr 13 '23 13:04 KOLANICH

@ian-abbott:

It wanted me to rename it to both num_transition_times and num_transition_types. I worked around it by using num_transitions + 0.

There is no point in suppressing these harmless warnings at any cost. These warnings are only meant to help a bit with sticking some of the https://doc.kaitai.io/ksy_style_guide.html#attr-id recommendations, but they are implemented quite naively (and can sometimes contradict each other, as in your case), so they cannot be followed without thinking.

So just use num_transitions and ignore the warning. It'll disappear once the compiler gets a bit more robust logic on whether to issue the warning or not.

generalmimon avatar Apr 13 '23 23:04 generalmimon

@generalmimon OK, I have removed the workaround that suppressed those harmless warnings. The only thing that is bugging me now is that I get this error when compiling for nim, perl, or rust:

tzif: /:
	error: an implementation is missing

ian-abbott avatar Apr 14 '23 09:04 ian-abbott

I wrote another tzif.ksy https://github.com/kaitai-io/kaitai_struct_formats/compare/master...moreati:kaitai_struct_formats:tzif. before I thought to check for open PRs. Sorry for the duplication.

Ian, do you still want to get yours merged? Would you like me to compare them and add review comments? Alternatively would you be interested in a PR against your branch - to then feed into this PR? Otherwise I'm happy to leave you in peace. You have priority, I don't want to usurp your effort/credit.

Edit: Emphasise mine is an unintended duplicate.

moreati avatar Apr 25 '24 11:04 moreati