diff options
Diffstat (limited to 'src/usr/ipmi')
-rw-r--r-- | src/usr/ipmi/ipmifruinv.C | 44 | ||||
-rw-r--r-- | src/usr/ipmi/ipmifruinvprvt.H | 4 |
2 files changed, 40 insertions, 8 deletions
diff --git a/src/usr/ipmi/ipmifruinv.C b/src/usr/ipmi/ipmifruinv.C index a2e3a5eba..1e13579be 100644 --- a/src/usr/ipmi/ipmifruinv.C +++ b/src/usr/ipmi/ipmifruinv.C @@ -437,16 +437,44 @@ errlHndl_t IpmiFruInv::formatMfgData(std::vector<uint8_t> i_mfgDateData, // Subtract month uint8_t numOfMonths = month - 1; // Subtract day - uint8_t numOfDays = day - 1; + uint16_t numOfDays = day - 1; - // Convert into minutes + // Add the specific number of days for the months given + for (uint8_t i=0; i < numOfMonths; i++) + { + numOfDays += daysInMonth[i]; + } + + // Add the number of days for the number of year given + numOfDays += (numOfYears*365); + + // Add a day for every leap year + // Check if we need to consider the current year + if (month <= 2) + { + // We don't need to consider this year for a leap year, as it + // wouldn't have happened yet. Decrement a year. + year = year - 1; + } - // TODO: RTC 172125 - // At some point we should take into account leap year and specific - // days in a month. - o_mfgDate = ((((numOfYears*365)*24)*60) + - (((numOfMonths*30.42)*24)*60) + ((numOfDays*24)*60) + - (hour*60) + minute); + uint8_t numLeapYears = 0; + // For every year from 1996 until the build date year, check if it's a + // leap year + for(uint16_t i = 1996; i <= (century*100 + year); i++) + { + // If the year is divisible by 4, its a leap year. Don't have to + // worry about centuries since the only possible century is 2000 + // and it was a leap year. + if(i % 4 == 0) + { + numLeapYears++; + } + } + + numOfDays += numLeapYears; + + // Convert into minutes + o_mfgDate = (((numOfDays*24)*60) + (hour*60) + minute); } diff --git a/src/usr/ipmi/ipmifruinvprvt.H b/src/usr/ipmi/ipmifruinvprvt.H index a2a15585a..61c1ab7e7 100644 --- a/src/usr/ipmi/ipmifruinvprvt.H +++ b/src/usr/ipmi/ipmifruinvprvt.H @@ -256,6 +256,10 @@ class IpmiFruInv VPD_SN_PN_VPD_SIZE = 16, }; + // Store number of days in a each month for computation of build date + const uint8_t daysInMonth[12] = {31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31}; + private: /** * @brief Compute and Add data checsum to data record |