This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Christian,
> I have found a bug in the deprecated udunits 1.12.9. I thought that you may
> be interested as this version is still used by many.
>
> I used utCalendar and, in some occasions, I had minutes==60 in the returned
> values by the function, which caused my program to fail.
Interesting. I would not have thought that possible. Thanks for sending this
in.
> Here is the fix:
> in src/lib/utlib.c:
>
> Starting line #445
>
> Before fix:
> if ((float)seconds >= 60) {
> seconds -= 60;
> if (++minutes >= 60) {
> minutes -= 60;
> if (++hours >= 24) {
> hours -= 24;
> days++;
> }
> }
> }
>
>
> After fix:
> if ((float)seconds >= 60) {
> seconds -= 60;
> if (++minutes >= 60) {
> minutes -= 60;
> if (++hours >= 24) {
> hours -= 24;
> days++;
> }
> }
> }
> else if (minutes >= 60) {
> minutes -= 60;
> if (++hours >= 24) {
> hours -= 24;
> days++;
> }
> }
> else if (hours >= 24) {
> hours -= 24;
> days++;
> }
I added a fix similar to this and made a new release.
Again, thanks!
> Regards,
>
> Christian Pagé
Regards,
Steve Emmerson
Ticket Details
===================
Ticket ID: VZB-644403
Department: Support UDUNITS
Priority: Normal
Status: Closed