From 8e4a54868c87fe20c1825861d6ed3f66c5927dfa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 24 Feb 2023 16:03:33 +0300 Subject: =?UTF-8?q?fixes=20#3130=20(WhenWasIt=20=D0=B2=D0=B5=D0=B4=D1=91?= =?UTF-8?q?=D1=82=20=D1=81=D0=B5=D0=B1=D1=8F=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/WhenWasIt/src/date_utils.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'plugins/WhenWasIt/src/date_utils.cpp') diff --git a/plugins/WhenWasIt/src/date_utils.cpp b/plugins/WhenWasIt/src/date_utils.cpp index 179d9174f1..5ae9d36a07 100644 --- a/plugins/WhenWasIt/src/date_utils.cpp +++ b/plugins/WhenWasIt/src/date_utils.cpp @@ -33,17 +33,12 @@ bool IsDOBValid(int, int month, int day) return (month != 0 && day != 0); } -const char* GetModule(MCONTACT hContact, int mode) -{ - return (mode == DOB_PROTOCOL) ? Proto_GetBaseAccountName(hContact) : "UserInfo"; -} - int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day, int iModule) { if (iModule != DOB_PROTOCOL) { - year = db_get_w(hContact, "UserInfo", "BirthYear", 0); - month = db_get_b(hContact, "UserInfo", "BirthMonth", 0); - day = db_get_b(hContact, "UserInfo", "BirthDay", 0); + year = db_get_w(hContact, "UserInfo", "BirthYear"); + month = db_get_b(hContact, "UserInfo", "BirthMonth"); + day = db_get_b(hContact, "UserInfo", "BirthDay"); if (IsDOBValid(year, month, day)) return DOB_USERINFO; if (iModule == DOB_USERINFO) @@ -51,9 +46,9 @@ int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day, int iModul } char *szProto = Proto_GetBaseAccountName(hContact); - year = db_get_w(hContact, szProto, "BirthYear", 0); - month = db_get_b(hContact, szProto, "BirthMonth", 0); - day = db_get_b(hContact, szProto, "BirthDay", 0); + year = db_get_w(hContact, szProto, "BirthYear"); + month = db_get_b(hContact, szProto, "BirthMonth"); + day = db_get_b(hContact, szProto, "BirthDay"); if (IsDOBValid(year, month, day)) return DOB_PROTOCOL; @@ -178,9 +173,12 @@ void DeleteBirthday(MCONTACT hContact) void SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode) { - auto *szModule = GetModule(hContact, mode); + auto *szModule = (mode == DOB_PROTOCOL) ? Proto_GetBaseAccountName(hContact) : "UserInfo"; db_set_dw(hContact, szModule, "BirthYear", year); db_set_b(hContact, szModule, "BirthMonth", month); db_set_b(hContact, szModule, "BirthDay", day); + + int age = GetContactAge(year, month, day); + db_set_b(hContact, szModule, "Age", age); } -- cgit v1.2.3