diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-03-20 17:15:42 +0300 |
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-03-20 17:15:42 +0300 |
| commit | b07063023ffb6bac667bb865e4d30212b88ff8e2 (patch) | |
| tree | 3ab8ee290d8cdfe25f1ef0c5bc6f1127367a3be0 /src | |
| parent | 0be93f29ef172bc008e4b5787f3d01a39c06dad9 (diff) | |
core helper for setting birthday & age
Diffstat (limited to 'src')
| -rw-r--r-- | src/mir_app/src/clistcontacts.cpp | 20 | ||||
| -rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
| -rw-r--r-- | src/mir_app/src/mir_app64.def | 1 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/mir_app/src/clistcontacts.cpp b/src/mir_app/src/clistcontacts.cpp index 759bce6f52..77fefe36af 100644 --- a/src/mir_app/src/clistcontacts.cpp +++ b/src/mir_app/src/clistcontacts.cpp @@ -296,6 +296,26 @@ MIR_APP_DLL(bool) Contact::IsGroupChat(MCONTACT hContact, const char *szProto) return db_get_b(hContact, szProto, "ChatRoom") != 0; } +MIR_APP_DLL(void) Contact::SetBirthday(MCONTACT hContact, int dd, int mm, int yy) +{ + if (auto *szProto = Proto_GetBaseAccountName(hContact)) { + db_set_w(hContact, szProto, "BirthMonth", mm); + db_set_w(hContact, szProto, "BirthDay", dd); + + if (yy) { + db_set_w(hContact, szProto, "BirthYear", yy); + + SYSTEMTIME sToday = {}; + GetLocalTime(&sToday); + int nAge = sToday.wYear - yy; + if (sToday.wMonth < mm || (sToday.wMonth == mm && sToday.wDay < dd)) + nAge--; + if (nAge) + db_set_w(hContact, szProto, "Age", nAge); + } + } +} + /////////////////////////////////////////////////////////////////////////////// MIR_APP_DLL(bool) Contact::IsHidden(MCONTACT hContact) diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index f38c665f8b..1dd24ecab3 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -997,3 +997,4 @@ Proto_CanDeleteHistory @1118 NONAME ?iHistoryMode@Srmm@@3V?$CMOption@E@@A @1128 NONAME
?getConn@MWebSocket@@QBEPAXXZ @1129 NONAME
?Chat_GetStatus@@YGPAUSTATUSINFO@@PAUSESSION_INFO@@PBUUSERINFO@@@Z @1130 NONAME
+?SetBirthday@Contact@@YGXIHHH@Z @1131 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 54d6d48c19..5e7b681246 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -997,3 +997,4 @@ Proto_CanDeleteHistory @1118 NONAME ?iHistoryMode@Srmm@@3V?$CMOption@E@@A @1128 NONAME
?getConn@MWebSocket@@QEBAPEAXXZ @1129 NONAME
?Chat_GetStatus@@YAPEAUSTATUSINFO@@PEAUSESSION_INFO@@PEBUUSERINFO@@@Z @1130 NONAME
+?SetBirthday@Contact@@YAXIHHH@Z @1131 NONAME
|
