freeipmi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freeipmi-devel] [bug #31769] Leap years are not included into the f


From: Al Chu
Subject: Re: [Freeipmi-devel] [bug #31769] Leap years are not included into the formula
Date: Thu, 02 Dec 2010 10:40:15 -0800

As an FYI, it appears this bug disappeared off the Savannah website due
to the restore from backup.  I've recreated it and is now bug #31758.

Al

On Thu, 2010-11-25 at 13:51 -0800, anonymous wrote:
> URL:
>   <http://savannah.gnu.org/bugs/?31769>
> 
>                  Summary: Leap years are not included into the formula
>                  Project: GNU FreeIPMI
>             Submitted by: None
>             Submitted on: Thu 25 Nov 2010 09:51:25 PM UTC
>                 Category: libfreeipmi
>                 Severity: 3 - Normal
>                 Priority: 5 - Normal
>               Item Group: Improper Behaviour
>                   Status: None
>                  Privacy: Public
>              Assigned to: None
>              Open/Closed: Open
>          Discussion Lock: Any
>         Operating System: GNU/Linux
> 
>     _______________________________________________________
> 
> Details:
> 
> Hello,
> 
> 
> I want to inform you about a possible bug in your library.
> It touches the calculation of the difference in epoch
> 
> 
> file: freeipmi-0.8.11/libfreeipmi/src/fru-parse/ipmi-fru-parse-data.c
> 336.      /* In FRU, epoch is 0:00 hrs 1/1/96
> 337.       *
> 338.       * So convert into ansi epoch
> 339.       *
> 340.       * 26 years difference in epoch
> 341.       * 365 days/year
> 342.       * etc.
> 343.       *
> 344.       */
> 345.      mfg_date_time_tmp += (26 * 365 * 24 * 60 * 60);
> 346.      (*mfg_date_time) = mfg_date_time_tmp;
> 
> 
> This formula doesn't take leap years and so it misses six days
> Years: 1972, 1976, 1980, 1984, 1988, 1992
> 
> 
> Here are GNU date output in comparison to your formula:
> $ date -d "1996-01-01 00:00:00" +%s
>   820447200
> $ calc "26 * 365 * 24 * 60 * 60"
>   819936000
> 
> 
> I'm not certain with the whole library architecture. Maybe you are
> correcting
> this in some other place or there is a doublebug? Please check if it is not
> better to use something like this:
> 
> // this code gives the same result as `date`
> #include <stdio.h>
> #include <time.h>
> 
> int main()
> {
>     struct tm t;
> 
>     t.tm_year = 96;
>     t.tm_mon = 0;
>     t.tm_mday = 1;
>     t.tm_hour = 0;
>     t.tm_min = 0;
>     t.tm_sec = 0;
> 
>     time_t result = mktime(&t);
> 
>     printf("1996-01-01 00:00:00 = %d\n", result);
> 
>     return 0;
> }
> 
> 
> Appreciate your work.
> BR
> 
> 
> 
> 
>     _______________________________________________________
> 
> Reply to this item at:
> 
>   <http://savannah.gnu.org/bugs/?31769>
> 
> _______________________________________________
>   Message sent via/by Savannah
>   http://savannah.gnu.org/
> 
> 
> _______________________________________________
> Freeipmi-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/freeipmi-devel
-- 
Albert Chu
address@hidden
Computer Scientist
High Performance Systems Division
Lawrence Livermore National Laboratory




reply via email to

[Prev in Thread] Current Thread [Next in Thread]