'Expiration Date Based on Shelf_Life
I don't know what is wrong with my code. My code works if the shelf_life is over 1 year. But if the shelf_life is 6 months. It expired very short. It takes only 3 months and it is already expired. But the shelf_life is 6 months. What am I going to do ? What is lacking in my code ?
Week Code: 2138 (2021 week 38)
Shelf_life : 6 months
CTime tt, t11;
CString Cweek, Cyear;
int yy, mm, wknum, yrnum;
tt = CTime::GetCurrentTime();
yy = tt.GetYear();
mm = tt.GetMonth();
wknum = atoi(tt.Format("%U"));
yrnum = atoi(tt.Format("%y"));
t11 = CTime(yy, 1, 1, 0, 0, 0);
if (t11.GetDayOfWeek() != 1)
wknum = wknum + 1;
Cweek.Format("%01d", wknum);
Cyear.Format("%02d", yrnum);
CTimeSpan shelf_no = CTimeSpan(atoi(view->m_pODBCPartsNo->m_shelf_life), 0, 0, 0);
CTime expiration_date = t11 + shelf_no;
Week code is a date code, for example 2138, year 2021(21) week 38(38). Week 38 is around September 19, 2021 to September 25, 2021.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
