summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2013-07-17 07:53:04 +0000
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>2013-07-17 07:53:04 +0000
commit04a3cfa78a3a0305296c9d5172fff4b1e14bd545 (patch)
tree09c5f5a2684efb93626f7e3b05202e3320a80353
parentda275244e3b21ece58610458a7cefa5bf70a1466 (diff)
downloadedk2-04a3cfa78a3a0305296c9d5172fff4b1e14bd545.zip
edk2-04a3cfa78a3a0305296c9d5172fff4b1e14bd545.tar.gz
edk2-04a3cfa78a3a0305296c9d5172fff4b1e14bd545.tar.bz2
Per gmtime manpage, tm_mon is the number of months since January
while MonthNo is the month of the year, so tm_mon should be MonthNo-1. Similarly, tm_mday is the day of the month, and DayNo is the number of days since the first day of the month. Assigning DayNo+1 to tm_mday to fit the definition. This commit also corrected miscalculated MonthNo and DayNo for the first day of the month. (Thanks to Laszlo Ersek!) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Gary Ching-Pang Lin <glin@suse.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Long Qin <qin.long@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14481 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index 805e6b4..6422d61 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -148,14 +148,14 @@ struct tm * gmtime (const time_t *timer)
GmTime->tm_yday = (int) DayNo;
for (MonthNo = 12; MonthNo > 1; MonthNo--) {
- if (DayNo > CumulativeDays[IsLeap(Year)][MonthNo]) {
+ if (DayNo >= CumulativeDays[IsLeap(Year)][MonthNo]) {
DayNo = (UINT16) (DayNo - (UINT16) (CumulativeDays[IsLeap(Year)][MonthNo]));
break;
}
}
- GmTime->tm_mon = (int) MonthNo;
- GmTime->tm_mday = (int) DayNo;
+ GmTime->tm_mon = (int) MonthNo - 1;
+ GmTime->tm_mday = (int) DayNo + 1;
GmTime->tm_isdst = 0;
GmTime->tm_gmtoff = 0;