From: Konrad Rosenbaum Date: Sat, 25 Apr 2020 10:39:39 +0000 (+0200) Subject: fix some compiler warnings; refactor TZDB update for easier GIT diff X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=dad1935c32cb9acda45985c2aed2dfed871576d3;p=web%2Fkonrad%2Ftzone.git fix some compiler warnings; refactor TZDB update for easier GIT diff --- diff --git a/src/tzfile.cpp b/src/tzfile.cpp index 904188d..5a51643 100644 --- a/src/tzfile.cpp +++ b/src/tzfile.cpp @@ -39,6 +39,15 @@ using namespace TimeZoneLib; NoDebug& operator<<(bool){return*this;} }; #endif + +//qSort is deprecated, long live lSort +#include + +template +static inline void lSort(Cont &c) +{ + std::sort(c.begin(),c.end()); +} /* ************************************************************** @@ -284,7 +293,7 @@ int TZFile::load(const QByteArray& a,char tversion) m_posix=PosixRule(posix); //sort and add end times - qSort(m_file); + lSort(m_file); for(int i=0;i<(m_file.size()-1);i++) m_file[i].setEnd(m_file[i+1].startTime()); if(m_file.size()) @@ -712,7 +721,7 @@ QList< TZRule > PosixRule::rulesForYear(int year) const else ret< #include +#ifndef Q_FALLTHROUGH +//introduced in Qt 5.14, for backward compat: +#define Q_FALLTHROUGH() +#endif + namespace TimeZoneLib { /**the amount of seconds per Day*/ @@ -69,17 +74,17 @@ inline qint64 daysSinceEpoch(int year,int month=1,int day=1) //calculate 1st of month // for each month: add the days of the previous one, and the previous, ... switch(month){ - case 12:ret+=30;//nov - case 11:ret+=31;//oct - case 10:ret+=30;//sep - case 9:ret+=31;//aug - case 8:ret+=31;//jul - case 7:ret+=30;//jun - case 6:ret+=31;//may - case 5:ret+=30;//apr - case 4:ret+=31;//mar - case 3:ret+=28;if(isLeapYear(year))ret++;//feb - case 2:ret+=31;//jan + case 12:ret+=30;Q_FALLTHROUGH(); //nov + case 11:ret+=31;Q_FALLTHROUGH(); //oct + case 10:ret+=30;Q_FALLTHROUGH(); //sep + case 9:ret+=31;Q_FALLTHROUGH(); //aug + case 8:ret+=31;Q_FALLTHROUGH(); //jul + case 7:ret+=30;Q_FALLTHROUGH(); //jun + case 6:ret+=31;Q_FALLTHROUGH(); //may + case 5:ret+=30;Q_FALLTHROUGH(); //apr + case 4:ret+=31;Q_FALLTHROUGH(); //mar + case 3:ret+=28;if(isLeapYear(year))ret++;Q_FALLTHROUGH(); //feb + case 2:ret+=31;Q_FALLTHROUGH(); //jan default:break; } //add day diff --git a/db/update.sh b/update-timedb.sh similarity index 97% rename from db/update.sh rename to update-timedb.sh index b49a7bb..d81dc20 100755 --- a/db/update.sh +++ b/update-timedb.sh @@ -3,9 +3,10 @@ set -e cd `dirname $0` +cd db echo Cleaning up. -rm -f tzdata* tzcode* +rm -f *