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:
68
core/user.h
68
core/user.h
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "timezone.h"
|
||||
#include "space/space.h"
|
||||
#include "date/date.h"
|
||||
|
||||
@@ -75,10 +76,6 @@ struct User
|
||||
int notify;
|
||||
|
||||
|
||||
// !! currently all users have the same offset
|
||||
// option in config: time_zone_offset
|
||||
int time_zone_offset;
|
||||
|
||||
// environment variables which can be set by this user
|
||||
// use 'env' winix function
|
||||
PT::Space env;
|
||||
@@ -92,69 +89,18 @@ struct User
|
||||
// a user can normally login only when status is WINIX_ACCOUNT_READY
|
||||
int status;
|
||||
|
||||
|
||||
|
||||
// time zone
|
||||
// values here are the same as those in env space
|
||||
// we provide they here to speed up the process of calculating times
|
||||
|
||||
// time zone offset
|
||||
time_t tz_offset;
|
||||
|
||||
// true if the time zone has daylight saving time
|
||||
bool tz_has_dst;
|
||||
|
||||
// time zone daylight saving time (used if tz_has_dst is true)
|
||||
// the 'year' field is ignored
|
||||
PT::Date tz_dst_start, tz_dst_end;
|
||||
TimeZone time_zone;
|
||||
|
||||
|
||||
|
||||
User()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
User();
|
||||
|
||||
|
||||
void Clear()
|
||||
{
|
||||
id = -1;
|
||||
name.clear();
|
||||
super_user = false;
|
||||
groups.clear();
|
||||
email.clear();
|
||||
notify = 0;
|
||||
time_zone_offset = 0;
|
||||
env.Clear();
|
||||
aenv.Clear();
|
||||
status = WINIX_ACCOUNT_BLOCKED;
|
||||
tz_offset = 0;
|
||||
tz_has_dst = false;
|
||||
tz_dst_start.Clear();
|
||||
tz_dst_end.Clear();
|
||||
}
|
||||
|
||||
|
||||
bool IsMemberOf(long group)
|
||||
{
|
||||
std::vector<long>::iterator i;
|
||||
|
||||
for(i=groups.begin() ; i!=groups.end() ; ++i)
|
||||
if( *i == group )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// lepsza nazwe dac
|
||||
void SetTz()
|
||||
{
|
||||
tz_offset = env.Long(L"tz_offset");
|
||||
|
||||
|
||||
|
||||
}
|
||||
void Clear();
|
||||
bool IsMemberOf(long group);
|
||||
bool ReadMonthDayTime(PT::Date & date, const wchar_t * str);
|
||||
bool SetTzFromEnv();
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user