feat(Core/Common): add new helpers for time utility (#10207)

This commit is contained in:
Kargatum
2022-01-19 12:01:59 +07:00
committed by GitHub
parent b5ab409614
commit 259b9133f6
60 changed files with 732 additions and 341 deletions

View File

@@ -1890,11 +1890,8 @@ public:
{
case EVENT_TIME:
{
// Get how many times it should ring
time_t t = time(nullptr);
tm local_tm;
tzset(); // set timezone for localtime_r() -> fix issues due to daylight time
localtime_r(&t, &local_tm);
tm local_tm = Acore::Time::TimeBreakdown();
uint8 _rings = (local_tm.tm_hour) % 12;
_rings = (_rings == 0) ? 12 : _rings; // 00:00 and 12:00

View File

@@ -119,9 +119,7 @@ public:
{
case EVENT_CLEARWATER_ANNOUNCE:
{
time_t curtime = time(nullptr);
tm strdate;
localtime_r(&curtime, &strdate);
tm strdate = Acore::Time::TimeBreakdown();
if (!preWarning && strdate.tm_hour == 13 && strdate.tm_min == 55)
{
@@ -268,14 +266,14 @@ public:
{
case EVENT_RIGGLE_ANNOUNCE:
{
time_t curtime = time(nullptr);
tm strdate;
localtime_r(&curtime, &strdate);
tm strdate = Acore::Time::TimeBreakdown();
if (!startWarning && strdate.tm_hour == 14 && strdate.tm_min == 0)
{
sCreatureTextMgr->SendChat(me, RIGGLE_SAY_START, 0, CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, TEXT_RANGE_ZONE);
startWarning = true;
}
if (!finishWarning && strdate.tm_hour == 16 && strdate.tm_min == 0)
{
sCreatureTextMgr->SendChat(me, RIGGLE_SAY_END, 0, CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, TEXT_RANGE_ZONE);