bugGNU FreeIPMI - Bugs: bug #31758, Leap years are not included into...

 
 

bug #31758: Leap years are not included into the formula

Submitted by:  Albert Chu <chu11>
Submitted on:  Thu 02 Dec 2010 06:39:58 PM UTC  
 
Category: libfreeipmiSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Improper Behaviour
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Operating System: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 03 Dec 2010 01:01:23 AM UTC, comment #2:

Should be fixed in the next release of FreeIPMI (0.8.12)

Albert Chu <chu11>
Project Administrator
Thu 02 Dec 2010 06:43:31 PM UTC, comment #1:

(Note: Due to Savannah restore, original bug disappeared. This bug is a resubmission from user "BR")

BR,

I think you're absolutely right. There is a leap year calculation bug. I'll need to look into how to do this right and in a way that's portable, but your suggestion below is probably right on target with what I should do.

Thanks,
Al

Albert Chu <chu11>
Project Administrator
Thu 02 Dec 2010 06:39:58 PM UTC, original submission:

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

Albert Chu <chu11>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by chu11 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 03 Dec 2010 01:01:23 AM UTCchu11Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1