summaryrefslogtreecommitdiffstats
path: root/src/usr/ipmi
diff options
context:
space:
mode:
authorMatt Ploetz <maploetz@us.ibm.com>2017-05-16 21:30:43 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-05-22 16:22:08 -0400
commit1be038e7e43d6583bfdf145adfc0eef697e83c5d (patch)
tree0cd54730ae8affaebf16742eb9af5009bcc88b2a /src/usr/ipmi
parent211c307ccf7a82bbabeba2e6c9a03ddfd3afea40 (diff)
downloadtalos-hostboot-1be038e7e43d6583bfdf145adfc0eef697e83c5d.tar.gz
talos-hostboot-1be038e7e43d6583bfdf145adfc0eef697e83c5d.zip
Add leap year and days of month into build date for ipmi fru inv
Change-Id: I6c378db6aad5cc1ff2d93d2a220e8dbc4a934f7b RTC:172125 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/40664 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com> Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com> Reviewed-by: Prachi Gupta <pragupta@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/ipmi')
-rw-r--r--src/usr/ipmi/ipmifruinv.C44
-rw-r--r--src/usr/ipmi/ipmifruinvprvt.H4
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
OpenPOWER on IntegriCloud