From 4a8c783de7fad2c94d0be94549904d7c542a7e74 Mon Sep 17 00:00:00 2001 From: piaip Date: Tue, 8 Sep 2009 07:01:02 +0000 Subject: * message refine * adjust login time base (must consider timezone when rounding to midnight) git-svn-id: http://opensvn.csie.org/pttbbs/branches/pttbbs.pwcu@4821 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/passwd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mbbsd/passwd.c') diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index bfb64224..cfddca87 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -1,6 +1,7 @@ /* $Id$ */ #define PWCU_IMPL #include "bbs.h" +#include "time.h" #ifdef _BBS_UTIL_C_ #error sorry, mbbsd/passwd.c does not support utility mode anymore. please use libcmbbs instead. @@ -442,7 +443,9 @@ int pwcuLoginSave () // was decided. int regdays = 0, prev_regdays = 0; int reftime = login_start_time; - time4_t baseref = 0; + time4_t baseref = 0; + struct tm baseref_tm = {0}; + PWCU_START(); // new host from 'fromhost' @@ -453,7 +456,12 @@ int pwcuLoginSave () assert(login_start_time > 0); // adjust base reference by rounding to beginning of each day (0:00am) - baseref = u.firstlogin - (u.firstlogin % DAY_SECONDS); + baseref = u.firstlogin; + if (localtime4_r(&baseref, &baseref_tm)) + { + baseref_tm.tm_sec = baseref_tm.tm_min = baseref_tm.tm_hour = 0; + baseref = mktime(&baseref_tm); + } // invalid session? if (reftime < u.lastlogin) -- cgit v1.2.3