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
GmTime->tm_yday = (int) DayNo;\r
\r
for (MonthNo = 12; MonthNo > 1; MonthNo--) {\r
- if (DayNo > CumulativeDays[IsLeap(Year)][MonthNo]) {\r
+ if (DayNo >= CumulativeDays[IsLeap(Year)][MonthNo]) {\r
DayNo = (UINT16) (DayNo - (UINT16) (CumulativeDays[IsLeap(Year)][MonthNo]));\r
break;\r
}\r
}\r
\r
- GmTime->tm_mon = (int) MonthNo;\r
- GmTime->tm_mday = (int) DayNo;\r
+ GmTime->tm_mon = (int) MonthNo - 1;\r
+ GmTime->tm_mday = (int) DayNo + 1;\r
\r
GmTime->tm_isdst = 0;\r
GmTime->tm_gmtoff = 0;\r