summaryrefslogtreecommitdiff
path: root/plugins/WhenWasIt/src/date_utils.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-02-24 16:03:33 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-02-24 16:03:33 +0300
commit8e4a54868c87fe20c1825861d6ed3f66c5927dfa (patch)
tree389d343d7fe855fb725f900abd3ac4c1cc4565a2 /plugins/WhenWasIt/src/date_utils.cpp
parent71fcd78ec9a08c7d613f57620fff155d7681d4ef (diff)
fixes #3130 (WhenWasIt ведёт себя странно)
Diffstat (limited to 'plugins/WhenWasIt/src/date_utils.cpp')
-rw-r--r--plugins/WhenWasIt/src/date_utils.cpp22
1 files changed, 10 insertions, 12 deletions
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);
}