From: konrad Date: Fri, 9 Jul 2010 10:43:13 +0000 (+0000) Subject: some minor attempt at fixing posix rules X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9d248a68c692ce6ff1ea19eea2791670c24c187a;p=web%2Fkonrad%2Ftzone.git some minor attempt at fixing posix rules added posix rule scanner git-svn-id: https://silmor.de/svn/softmagic/tzone/trunk@548 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/pscan/pscan.cpp b/pscan/pscan.cpp new file mode 100644 index 0000000..bcf6eec --- /dev/null +++ b/pscan/pscan.cpp @@ -0,0 +1,70 @@ +// This is a very simple POSIX Rule Scanner +// I used it to find the possible variations in the fallback POSIX rules of the TZ DB + +#include +#include "../tzfile.h" + +bool verbose=false; + +void scanFile(QString fn) +{ + using namespace TimeZoneLib; + QFile fd(fn); + if(!fd.open(QIODevice::ReadOnly)){ + if(verbose) + qDebug()<<"file unreadable"< PosixRule::rulesForYear(int year) const @@ -579,27 +579,27 @@ QList< TZRule > PosixRule::rulesForYear(int year) const start.m_abbr=m_abbrdst; start.m_off=m_offdst; start.m_isdst=true; - start.m_start=calcTimeStamp(year,m_types,m_months,m_weeks,m_days,m_times+m_off); + start.m_start=calcTimeStamp(year,m_types,m_months,m_weeks,m_days,m_times,m_off); //calculate end end.m_abbr=m_abbr; end.m_off=m_off; end.m_isdst=false; - end.m_start=calcTimeStamp(year,m_typee,m_monthe,m_weeke,m_daye,m_timee+m_offdst); + end.m_start=calcTimeStamp(year,m_typee,m_monthe,m_weeke,m_daye,m_timee,m_offdst); //calculate end of rules if(endret; @@ -622,8 +622,15 @@ TZRule PosixRule::ruleForTime(qint64 ) const return TZRule(); } -TZRule PosixRule::ruleForLocalTime ( qint64 ) const +TZRule PosixRule::ruleForLocalTime ( qint64 ts) const { + //calculate local time - we need the year + qint16 y; + quint8 mo,d,h,mi,s; + stamp2Date(ts,y,mo,d); + stamp2Time(ts,h,mi,s); + //is it standard or DST? + #warning not implemented //TODO!!! return TZRule(); diff --git a/tzfile.h b/tzfile.h index 29f7b11..fb46528 100644 --- a/tzfile.h +++ b/tzfile.h @@ -168,6 +168,15 @@ class TZFile /**returns a rule that matches a specific local time, the timestamp given is a Unix timestamp plus the offset of the rule that will match; in other words it was calculated assuming UTC and now looks for a rule that will provide a correcting offset*/ TZRule ruleForLocalTime(qint64); + /**returns the list of rules that were encoded in the file*/ + QList fileRules()const{return m_file;} + + /**returns the fallback POSIX rule that was encoded in the file (or an invalid rule if there was none)*/ + PosixRule posixRule()const{return m_posix;} + + /**returns all currently cached rules that were auto-generated during the lifetime of this file object*/ + QList cachedRules()const{return m_cache;} + /**returns the search paths for time zone files*/ static QStringList searchPath(); /**sets new search paths for time zone files*/