added: a new directory "etc"
there'll be some generic config files for winix added: a new file in etc directory: time_zones_file list of time zones (not finished yet -- daylight saving time is needed) added: option to config: etc_dir a directory in which there are some config files used mainly when winix starts default: empty (means not for using) added: option to config: time_zones_file a file in etc_dir with time zones info default: time_zones.conf this is a Space structure with all time zones added: to system: TimeZones struct list of time zones read from etc/time_zones.conf git-svn-id: svn://ttmath.org/publicrep/winix/trunk@849 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -20,7 +20,7 @@ app.o: ../../ezc/src/stringconv.h ../../pikotools/utf8/utf8.h
|
||||
app.o: ../notify/notifythread.h ../core/basethread.h
|
||||
app.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
app.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
app.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
app.o: users.h groups.h group.h loadavg.h image.h threadmanager.h timezones.h
|
||||
app.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
app.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
app.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
@@ -74,21 +74,21 @@ config.o: ../notify/notifythread.h ../core/basethread.h
|
||||
config.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
config.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
config.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
config.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
config.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
config.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
config.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
config.o: ../functions/privchanger.h ../functions/chown.h
|
||||
config.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
config.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
config.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
config.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
config.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
config.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
config.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
config.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
config.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
config.o: ../functions/subject.h ../functions/template.h
|
||||
config.o: timezones.h sessionmanager.h sessioncontainer.h
|
||||
config.o: ../functions/functions.h ../functions/functionbase.h
|
||||
config.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
config.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
config.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
config.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
config.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
config.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
config.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
config.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
config.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
config.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
config.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
config.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
config.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
config.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -159,8 +159,8 @@ image.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
|
||||
image.o: ../../ezc/src/stringconv.h ../notify/notifythread.h
|
||||
image.o: ../core/basethread.h ../notify/templatesnotify.h ../core/users.h
|
||||
image.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
image.o: users.h groups.h group.h loadavg.h threadmanager.h plugin.h
|
||||
image.o: pluginmsg.h sessionmanager.h sessioncontainer.h
|
||||
image.o: users.h groups.h group.h loadavg.h threadmanager.h timezones.h
|
||||
image.o: plugin.h pluginmsg.h sessionmanager.h sessioncontainer.h
|
||||
image.o: ../functions/functions.h ../functions/functionbase.h
|
||||
image.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
image.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
@@ -204,7 +204,7 @@ job.o: ../../ezc/src/stringconv.h ../../pikotools/utf8/utf8.h
|
||||
job.o: ../notify/notifythread.h ../core/basethread.h
|
||||
job.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
job.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
job.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
job.o: users.h groups.h group.h loadavg.h image.h threadmanager.h timezones.h
|
||||
job.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
job.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
job.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
@@ -309,8 +309,8 @@ mounts.o: ../notify/notifythread.h ../core/basethread.h
|
||||
mounts.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
mounts.o: ugcontainer.h lastcontainer.h mountparser.h plugin.h pluginmsg.h
|
||||
mounts.o: system.h job.h basethread.h synchro.h crypt.h run.h users.h
|
||||
mounts.o: groups.h group.h loadavg.h image.h threadmanager.h sessionmanager.h
|
||||
mounts.o: sessioncontainer.h ../functions/functions.h
|
||||
mounts.o: groups.h group.h loadavg.h image.h threadmanager.h timezones.h
|
||||
mounts.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
mounts.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
mounts.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
mounts.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
@@ -351,21 +351,22 @@ plugin.o: ../../pikotools/utf8/utf8.h ../notify/notifythread.h
|
||||
plugin.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
plugin.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h
|
||||
plugin.o: mountparser.h crypt.h run.h users.h groups.h group.h loadavg.h
|
||||
plugin.o: image.h threadmanager.h sessionmanager.h sessioncontainer.h
|
||||
plugin.o: ../functions/functions.h ../functions/functionbase.h
|
||||
plugin.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
plugin.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
plugin.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
plugin.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
plugin.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
plugin.o: ../functions/env.h ../functions/last.h ../functions/login.h
|
||||
plugin.o: ../functions/logout.h ../functions/ln.h ../functions/ls.h
|
||||
plugin.o: ../functions/man.h ../functions/meta.h ../functions/mkdir.h
|
||||
plugin.o: ../functions/mv.h ../functions/nicedit.h ../functions/node.h
|
||||
plugin.o: ../functions/passwd.h ../functions/priv.h ../functions/pw.h
|
||||
plugin.o: ../functions/reload.h ../functions/rm.h ../functions/rmuser.h
|
||||
plugin.o: ../functions/sort.h ../functions/specialdefault.h
|
||||
plugin.o: ../functions/stat.h ../functions/subject.h ../functions/template.h
|
||||
plugin.o: image.h threadmanager.h timezones.h sessionmanager.h
|
||||
plugin.o: sessioncontainer.h ../functions/functions.h
|
||||
plugin.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugin.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
plugin.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
plugin.o: ../functions/privchanger.h ../functions/chown.h
|
||||
plugin.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
plugin.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
plugin.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
plugin.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
plugin.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
plugin.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
plugin.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
plugin.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
plugin.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
plugin.o: ../functions/subject.h ../functions/template.h
|
||||
plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
plugin.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
@@ -393,7 +394,7 @@ plugindata.o: ../../pikotools/utf8/utf8.h ../notify/notifythread.h
|
||||
plugindata.o: ../core/basethread.h ../notify/templatesnotify.h
|
||||
plugindata.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
plugindata.o: mounts.h mountparser.h crypt.h run.h users.h groups.h group.h
|
||||
plugindata.o: loadavg.h image.h threadmanager.h sessionmanager.h
|
||||
plugindata.o: loadavg.h image.h threadmanager.h timezones.h sessionmanager.h
|
||||
plugindata.o: sessioncontainer.h ../functions/functions.h
|
||||
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugindata.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
@@ -453,19 +454,20 @@ request.o: ../notify/notifythread.h ../core/basethread.h
|
||||
request.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
request.o: ugcontainer.h lastcontainer.h mounts.h mountparser.h crypt.h run.h
|
||||
request.o: users.h groups.h group.h loadavg.h image.h threadmanager.h
|
||||
request.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
request.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
request.o: ../core/synchro.h ../functions/functionparser.h ../core/cur.h
|
||||
request.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
request.o: ../functions/privchanger.h ../functions/chown.h
|
||||
request.o: ../functions/ckeditor.h ../functions/cp.h ../functions/default.h
|
||||
request.o: ../functions/download.h ../functions/emacs.h ../functions/env.h
|
||||
request.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
request.o: ../functions/ln.h ../functions/ls.h ../functions/man.h
|
||||
request.o: ../functions/meta.h ../functions/mkdir.h ../functions/mv.h
|
||||
request.o: ../functions/nicedit.h ../functions/node.h ../functions/passwd.h
|
||||
request.o: ../functions/priv.h ../functions/pw.h ../functions/reload.h
|
||||
request.o: ../functions/rm.h ../functions/rmuser.h ../functions/sort.h
|
||||
request.o: timezones.h sessionmanager.h sessioncontainer.h
|
||||
request.o: ../functions/functions.h ../functions/functionbase.h
|
||||
request.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
request.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
request.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
request.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
request.o: ../functions/default.h ../functions/download.h
|
||||
request.o: ../functions/emacs.h ../functions/env.h ../functions/last.h
|
||||
request.o: ../functions/login.h ../functions/logout.h ../functions/ln.h
|
||||
request.o: ../functions/ls.h ../functions/man.h ../functions/meta.h
|
||||
request.o: ../functions/mkdir.h ../functions/mv.h ../functions/nicedit.h
|
||||
request.o: ../functions/node.h ../functions/passwd.h ../functions/priv.h
|
||||
request.o: ../functions/pw.h ../functions/reload.h ../functions/rm.h
|
||||
request.o: ../functions/rmuser.h ../functions/sort.h
|
||||
request.o: ../functions/specialdefault.h ../functions/stat.h
|
||||
request.o: ../functions/subject.h ../functions/template.h
|
||||
request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
@@ -516,10 +518,10 @@ sessionmanager.o: ../../pikotools/utf8/utf8.h ../notify/notifythread.h
|
||||
sessionmanager.o: ../core/basethread.h ../notify/templatesnotify.h
|
||||
sessionmanager.o: ../core/config.h ../core/users.h ugcontainer.h mounts.h
|
||||
sessionmanager.o: mountparser.h crypt.h run.h users.h groups.h group.h
|
||||
sessionmanager.o: loadavg.h image.h threadmanager.h sessionparser.h plugin.h
|
||||
sessionmanager.o: pluginmsg.h ../functions/functions.h
|
||||
sessionmanager.o: ../functions/functionbase.h ../core/request.h
|
||||
sessionmanager.o: ../core/system.h ../core/synchro.h
|
||||
sessionmanager.o: loadavg.h image.h threadmanager.h timezones.h
|
||||
sessionmanager.o: sessionparser.h plugin.h pluginmsg.h
|
||||
sessionmanager.o: ../functions/functions.h ../functions/functionbase.h
|
||||
sessionmanager.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
sessionmanager.o: ../functions/functionparser.h ../core/cur.h
|
||||
sessionmanager.o: ../functions/adduser.h ../functions/cat.h
|
||||
sessionmanager.o: ../functions/chmod.h ../functions/privchanger.h
|
||||
@@ -579,7 +581,7 @@ system.o: ../../pikotools/utf8/utf8.h ../notify/notifythread.h
|
||||
system.o: ../core/basethread.h ../notify/templatesnotify.h ../core/config.h
|
||||
system.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h
|
||||
system.o: mountparser.h crypt.h run.h users.h groups.h group.h loadavg.h
|
||||
system.o: image.h threadmanager.h ../templates/templates.h
|
||||
system.o: image.h threadmanager.h timezones.h ../templates/templates.h
|
||||
system.o: ../templates/patterncacher.h ../templates/indexpatterns.h
|
||||
system.o: ../templates/patterns.h ../templates/changepatterns.h
|
||||
system.o: ../templates/htmltextstream.h ../core/cur.h ../core/system.h
|
||||
@@ -612,6 +614,14 @@ threadmanager.o: session.h user.h plugindata.h rebus.h mount.h
|
||||
threadmanager.o: ../templates/locale.h
|
||||
timezone.o: timezone.h ../../pikotools/date/date.h
|
||||
timezone.o: ../../pikotools/space/space.h
|
||||
timezones.o: timezones.h timezone.h ../../pikotools/date/date.h
|
||||
timezones.o: ../../pikotools/space/space.h
|
||||
timezones.o: ../../pikotools/space/spaceparser.h
|
||||
timezones.o: ../../pikotools/space/space.h misc.h item.h requesttypes.h log.h
|
||||
timezones.o: textstream.h logmanipulators.h slog.h cur.h request.h error.h
|
||||
timezones.o: config.h htmlfilter.h ../templates/htmltextstream.h
|
||||
timezones.o: ../core/textstream.h session.h user.h plugindata.h rebus.h
|
||||
timezones.o: mount.h ../templates/locale.h
|
||||
user.o: user.h
|
||||
users.o: users.h sessionmanager.h sessioncontainer.h session.h item.h
|
||||
users.o: ../../pikotools/space/space.h ../../pikotools/date/date.h error.h
|
||||
@@ -633,7 +643,7 @@ users.o: ../../ezc/src/stringconv.h ../../pikotools/utf8/utf8.h
|
||||
users.o: ../notify/notifythread.h ../core/basethread.h
|
||||
users.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
users.o: ugcontainer.h mounts.h mountparser.h crypt.h run.h groups.h group.h
|
||||
users.o: loadavg.h image.h threadmanager.h plugin.h pluginmsg.h
|
||||
users.o: loadavg.h image.h threadmanager.h timezones.h plugin.h pluginmsg.h
|
||||
users.o: ../functions/functions.h ../functions/functionbase.h
|
||||
users.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
users.o: ../functions/functionparser.h ../core/cur.h ../functions/adduser.h
|
||||
|
@@ -1 +1 @@
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o item.o job.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o user.o users.o
|
||||
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o crypt.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o image.o item.o job.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o run.o session.o sessioncontainer.o sessionmanager.o sessionparser.o slog.o synchro.o system.o threadmanager.o timezone.o timezones.o user.o users.o
|
||||
|
@@ -240,6 +240,9 @@ void Config::AssignValues(bool stdout_is_closed)
|
||||
|
||||
time_zone.SetTz(space);
|
||||
|
||||
etc_dir = Text(L"etc_dir", L"");
|
||||
time_zones_file = Text(L"time_zones_file", L"time_zones.conf");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -496,6 +496,24 @@ public:
|
||||
// "tz_dst_offset" (long)
|
||||
TimeZone time_zone;
|
||||
|
||||
// a directory in which there are some config files
|
||||
// used mainly when winix starts
|
||||
// default: empty (means not for using)
|
||||
std::wstring etc_dir;
|
||||
|
||||
// a file in etc_dir with time zones info
|
||||
// default: time_zones.conf
|
||||
// this is a Space structure with all time zones
|
||||
// with following format:
|
||||
// "tz_-12:00" ( # the name of a space is also a key to the locale files
|
||||
// tz_offset_str = "-12:00" # a string representing the offset from UTC in a format: [+|-]HH:MM
|
||||
// tz_has_dst = "false" # whether the time zone has daylight saving time (bool)
|
||||
// tz_dst_offset = "" # offset of the daylight saving time
|
||||
// tz_dst_start = "" # when the daylight saving time starts, format: MM:DD HH:MM:SS
|
||||
// tz_dst_end = "") # when the daylight saving time ends, format: MM:DD HH:MM:SS
|
||||
// each time zone is in a seperate space
|
||||
std::wstring time_zones_file;
|
||||
|
||||
|
||||
|
||||
Config();
|
||||
|
@@ -51,6 +51,28 @@ void System::SetSessionManager(SessionManager * sm)
|
||||
}
|
||||
|
||||
|
||||
void System::ReadTimeZones()
|
||||
{
|
||||
if( config->etc_dir.empty() )
|
||||
{
|
||||
log << log1 << "System: I cannot read time zones, set etc_dir directory in the config" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
if( config->time_zones_file.empty() )
|
||||
{
|
||||
log << log1 << "System:: I cannot read time zones, set time_zones_file in the config" << logend;
|
||||
return;
|
||||
}
|
||||
|
||||
name_temp = config->etc_dir;
|
||||
name_temp += '/';
|
||||
name_temp += config->time_zones_file;
|
||||
|
||||
time_zones.ReadTimeZones(name_temp);
|
||||
}
|
||||
|
||||
|
||||
void System::Init()
|
||||
{
|
||||
thread_manager.SetSynchro(synchro);
|
||||
@@ -93,6 +115,8 @@ void System::Init()
|
||||
// SetSynchro will be called by ThreadManager itself
|
||||
// job.ReadFromFile();
|
||||
thread_manager.Add(&job, L"job");
|
||||
|
||||
ReadTimeZones();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "image.h"
|
||||
#include "threadmanager.h"
|
||||
#include "notify/notify.h"
|
||||
#include "timezones.h"
|
||||
|
||||
|
||||
class Functions;
|
||||
@@ -73,6 +74,10 @@ public:
|
||||
// jobs
|
||||
Job job;
|
||||
|
||||
// time zones read from etc/time_zones.conf
|
||||
// when winix starts
|
||||
TimeZones time_zones;
|
||||
|
||||
|
||||
void SetCur(Cur * pcur);
|
||||
void SetConfig(Config * pconfig);
|
||||
@@ -161,6 +166,9 @@ public:
|
||||
|
||||
bool AddCommonFileToVar(const wchar_t * file_path, const wchar_t * url, bool overwrite_existing = true);
|
||||
|
||||
// reloading time zones
|
||||
void ReadTimeZones();
|
||||
|
||||
private:
|
||||
|
||||
Cur * cur;
|
||||
|
@@ -22,6 +22,7 @@ TimeZone::TimeZone()
|
||||
|
||||
void TimeZone::Clear()
|
||||
{
|
||||
tz_id = -1;
|
||||
tz_offset = 0;
|
||||
tz_has_dst = false;
|
||||
tz_dst_offset = 0;
|
||||
@@ -122,6 +123,7 @@ bool TimeZone::SetTz(PT::Space & space)
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
tz_id = space.Int(L"tz_id", -1);
|
||||
tz_offset = space.Long(L"tz_offset", 0);
|
||||
tz_has_dst = space.Bool(L"tz_has_dst", false);
|
||||
|
||||
|
@@ -32,8 +32,8 @@ public:
|
||||
|
||||
|
||||
/*
|
||||
reading zime zone values from Space struct
|
||||
the struct should have:
|
||||
reading zime zone values from Space struct (tz_id is skipped)
|
||||
the space struct should have:
|
||||
"tz_offset" (long)
|
||||
"tz_has_dst" (bool)
|
||||
if tz_has_dst is true then also:
|
||||
@@ -60,7 +60,8 @@ public:
|
||||
PT::Date ToUTC(const PT::Date & local_date);
|
||||
|
||||
|
||||
|
||||
// each locale has its own identifier
|
||||
int tz_id;
|
||||
|
||||
// time zone offset (in seconds)
|
||||
time_t tz_offset;
|
||||
|
163
core/timezones.cpp
Normal file
163
core/timezones.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "timezones.h"
|
||||
#include "misc.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
|
||||
TimeZones::TimeZones()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
time_t TimeZones::ParseOffset(const wchar_t * str)
|
||||
{
|
||||
PT::Date date;
|
||||
bool is_sign = false;
|
||||
time_t offset = 0;
|
||||
|
||||
str = SkipWhite(str);
|
||||
|
||||
if( *str == '-' )
|
||||
{
|
||||
is_sign = true;
|
||||
str += 1;
|
||||
}
|
||||
else
|
||||
if( *str == '+' )
|
||||
{
|
||||
str += 1;
|
||||
}
|
||||
|
||||
if( date.ParseTime(str) )
|
||||
{
|
||||
offset = date.hour * 60 * 60 + date.min * 60;
|
||||
|
||||
if( is_sign )
|
||||
offset = -offset;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
void TimeZones::ParseZones()
|
||||
{
|
||||
for(size_t i=0 ; i<temp_space.spaces.size() ; ++i)
|
||||
{
|
||||
PT::Space & zone = *temp_space.spaces[i];
|
||||
zone.Add(L"tz_offset", ParseOffset(zone.Text(L"tz_offset_str").c_str()));
|
||||
zone.Add(L"tz_dst_offset", ParseOffset(zone.Text(L"tz_dst_offset_str").c_str()));
|
||||
|
||||
temp_zone.Clear();
|
||||
|
||||
if( temp_zone.time_zone.SetTz(zone) )
|
||||
{
|
||||
temp_zone.name_key = zone.name;
|
||||
|
||||
if( !FindZone(temp_zone.time_zone.tz_id) )
|
||||
{
|
||||
tab.push_back(temp_zone);
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "Tz: zone with id: " << temp_zone.time_zone.tz_id
|
||||
<< " already exists (skipping)" << logend;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log << log1 << "System: problem with reading info from time zone: "
|
||||
<< zone.name << " (skipping) " << logend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! IMPROVE ME
|
||||
// in the future we do not have to read the whole file
|
||||
// just space by space (not implemented in Space at the moment)
|
||||
bool TimeZones::ReadTimeZones(const wchar_t * path)
|
||||
{
|
||||
parser.UTF8(true);
|
||||
parser.SetSpace(temp_space);
|
||||
tab.clear();
|
||||
|
||||
PT::SpaceParser::Status status = parser.Parse(path);
|
||||
|
||||
if( status == PT::SpaceParser::ok )
|
||||
{
|
||||
ParseZones();
|
||||
log << log2 << "Tz: time zones loaded, there are " << tab.size() << " zones" << logend;
|
||||
}
|
||||
else
|
||||
if( status == PT::SpaceParser::syntax_error )
|
||||
{
|
||||
log << log1 << "TZ: error in time zone file, line: " << parser.line << logend;
|
||||
}
|
||||
else
|
||||
if( status == PT::SpaceParser::cant_open_file )
|
||||
{
|
||||
log << log1 << "TZ: I cannot open the time zone file: " << path << logend;
|
||||
}
|
||||
|
||||
temp_space.Clear();
|
||||
|
||||
return status == PT::SpaceParser::ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TimeZones::ReadTimeZones(const std::wstring & path)
|
||||
{
|
||||
return ReadTimeZones(path.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TimeZones::Zone * TimeZones::FindZone(int tz_id)
|
||||
{
|
||||
for(size_t i=0 ; i<tab.size() ; ++i)
|
||||
{
|
||||
if( tab[i].time_zone.tz_id == tz_id )
|
||||
return &tab[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TimeZones::Zone & TimeZones::operator[](size_t index)
|
||||
{
|
||||
return tab[index];
|
||||
}
|
||||
|
||||
|
||||
size_t TimeZones::Size() const
|
||||
{
|
||||
return tab.size();
|
||||
}
|
||||
|
||||
|
||||
bool TimeZones::Empty() const
|
||||
{
|
||||
return tab.empty();
|
||||
}
|
||||
|
||||
|
||||
void TimeZones::Clear()
|
||||
{
|
||||
tab.clear();
|
||||
}
|
||||
|
66
core/timezones.h
Normal file
66
core/timezones.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This file is a part of Winix
|
||||
* and is not publicly distributed
|
||||
*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_timezones
|
||||
#define headerfile_winix_core_timezones
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "timezone.h"
|
||||
#include "space/spaceparser.h"
|
||||
|
||||
|
||||
|
||||
class TimeZones
|
||||
{
|
||||
public:
|
||||
|
||||
struct Zone
|
||||
{
|
||||
TimeZone time_zone;
|
||||
std::wstring name_key; // a key to locale
|
||||
|
||||
void Clear()
|
||||
{
|
||||
time_zone.Clear();
|
||||
name_key.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TimeZones();
|
||||
|
||||
|
||||
bool ReadTimeZones(const wchar_t * path);
|
||||
bool ReadTimeZones(const std::wstring & path);
|
||||
|
||||
Zone * FindZone(int tz_id);
|
||||
Zone & operator[](size_t index);
|
||||
size_t Size() const;
|
||||
bool Empty() const;
|
||||
void Clear();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::vector<Zone> Tab;
|
||||
Tab tab;
|
||||
PT::SpaceParser parser;
|
||||
PT::Space temp_space;
|
||||
Zone temp_zone;
|
||||
|
||||
time_t ParseOffset(const wchar_t * str);
|
||||
void ParseZones();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user