From 409a8d7b54419b779e6140926a31d7e6e1caac24 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Fri, 2 Jan 2015 12:26:21 +0000 Subject: UserInfoEx: fix for output age as 0 and empty birthday date when birthday.year==0 git-svn-id: http://svn.miranda-ng.org/main/trunk@11721 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/UserInfoEx/src/classMTime.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'plugins/UserInfoEx/src/classMTime.cpp') diff --git a/plugins/UserInfoEx/src/classMTime.cpp b/plugins/UserInfoEx/src/classMTime.cpp index 9ca9591b26..35955d4d14 100644 --- a/plugins/UserInfoEx/src/classMTime.cpp +++ b/plugins/UserInfoEx/src/classMTime.cpp @@ -344,6 +344,39 @@ WORD MTime::DateFormat(LPTSTR ptszTimeFormat, WORD cchTimeFormat) return cchTimeFormat; } +WORD MTime::DateFormatAlt(LPTSTR ptszTimeFormat, WORD cchTimeFormat) +{ + if (!ptszTimeFormat || !cchTimeFormat) + return 0; + + WORD wRes = DateFormat(ptszTimeFormat, cchTimeFormat); + if (wRes != 0) + return wRes; + + SYSTEMTIME AltSysTime = _SysTime; + MTime mtNow; + mtNow.GetLocalTime(); + AltSysTime.wYear=mtNow.Year(); + + if ((cchTimeFormat = GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &AltSysTime, NULL, ptszTimeFormat, cchTimeFormat)) == 0) { + *ptszTimeFormat = 0; + return 0; + } + + TCHAR tszText[10]; + _itot(mtNow.Year(), tszText, 10); + TCHAR * tszYear = _tcsstr(ptszTimeFormat, tszText); + + if (tszYear && mir_tstrlen(tszYear) == 4) + mir_tstrcpy(tszYear, _T("????")); + else { + *ptszTimeFormat = 0; + return 0; + } + + return cchTimeFormat; +} + WORD MTime::DateFormatLong(LPTSTR ptszTimeFormat, WORD cchTimeFormat) { if (!ptszTimeFormat || !cchTimeFormat) -- cgit v1.2.3