'How to decode a week code (ISO week date)
Is there a way on how to decode a week code or ISO week date using CTime
? I am currently creating an expiration date that is based on week code. I'm having a hard time adding the CTime
and CTimeSpan
(shelf_life
) because the output is not accurate.
If the shelf_life
is 6 months, my output is accurate. But when the shelf_life
is more than a year, the output is 4 months overdue.
This is my code:
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, mm, 1, 0, 0, 0);
if (t11.GetDayOfWeek() == 4)
wknum = wknum ++;
Cweek.Format("%02d", wknum);
Cyear.Format("%02d", yrnum);
CTimeSpan shelf_no = CTimeSpan(atoi(view->m_pODBCPartsNo->m_shelf_life), 0, 0, 0);
CTime expiration_date = tt + shelf_no;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|