added: TimeZone struct (core)

this class has information about a time zone (utf offset, daylight saving time)
       and methods for converting between UTC and local time
       structs User and Config has a TimeZone object
       System::ToLocal() and System::ToUTC() uses it for converting
       (depending whether a user is logged or not)


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@842 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-05-30 19:04:18 +00:00
parent 9d5d088b4a
commit ec773e5f29
31 changed files with 1505 additions and 1150 deletions

View File

@@ -71,7 +71,6 @@ void System::Init()
users.SetCur(cur);
users.SetSessionManager(session_manager);
users.ReadUsers(db);
users.SetTimeZoneOffset(config->time_zone_offset);
groups.ReadGroups(db); // !! chwilowe przekazanie argumentu, db bedzie zmienione
rebus.SetCur(cur);
@@ -870,29 +869,60 @@ return status;
}
// !! IMPROVE ME will be removed or changed
time_t System::LocalTime(time_t gmt_time)
time_t System::ToLocal(time_t gmt_time)
{
int time_offset;
time_t local_time;
if( cur->session && cur->session->puser )
time_offset = cur->session->puser->time_zone_offset;
local_time = cur->session->puser->time_zone.ToLocal(gmt_time);
else
time_offset = config->time_zone_offset_guest;
local_time = config->time_zone.ToLocal(gmt_time);
return gmt_time + (time_t)time_offset;
return local_time;
}
// !! IMPROVE ME will be removed or changed
PT::Date System::LocalTime(const PT::Date & date)
PT::Date System::ToLocal(const PT::Date & gmt_date)
{
time_t t;
PT::Date local_date;
t = date.ToTime();
t = LocalTime(t);
if( cur->session && cur->session->puser )
local_date = cur->session->puser->time_zone.ToLocal(gmt_date);
else
local_date = config->time_zone.ToLocal(gmt_date);
return PT::Date(t);
return local_date;
}
time_t System::ToUTC(time_t local_time)
{
time_t utc_time;
if( cur->session && cur->session->puser )
utc_time = cur->session->puser->time_zone.ToUTC(local_time);
else
utc_time = config->time_zone.ToUTC(local_time);
return utc_time;
}
PT::Date System::ToUTC(const PT::Date & local_date)
{
PT::Date utc_date;
if( cur->session && cur->session->puser )
utc_date = cur->session->puser->time_zone.ToUTC(local_date);
else
utc_date = config->time_zone.ToUTC(local_date);
return utc_date;
}