ionflux.org | Impressum

TimeZone.hpp

Go to the documentation of this file.
00001 #ifndef IONFLUX_TOOLS_TIMEZONE
00002 #define IONFLUX_TOOLS_TIMEZONE
00003 /* ==========================================================================
00004  * Ionflux Tools
00005  * Copyright (c) 2004 Joern P. Meier
00006  * mail@ionflux.org
00007  * --------------------------------------------------------------------------
00008  * TimeZone.hpp                    Time zone.
00009  * ==========================================================================
00010  * 
00011  * This file is part of Ionflux Tools.
00012  * 
00013  * Ionflux Tools is free software; you can redistribute it and/or modify it 
00014  * under the terms of the GNU General Public License as published by the Free
00015  * Software Foundation; either version 2 of the License, or (at  your option)
00016  * any later version.
00017  * 
00018  * Ionflux Tools is distributed in the hope that it will be useful, but 
00019  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00020  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00021  * for more details.
00022  * 
00023  * You should have received a copy of the GNU General Public License
00024  * along with Ionflux Tools; if not, write to the Free Software Foundation, 
00025  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00026  * 
00027  * ========================================================================== */
00028 
00029 #include <string>
00030 #include <iostream>
00031 #include "ionflux/DateTime.hpp"
00032 
00033 namespace Ionflux
00034 {
00035 
00036 namespace Tools
00037 {
00038 
00039 class DateTime;
00040 
00044 typedef int64_t TimeTicks;
00048 typedef int64_t Year;
00049 
00060 struct DSTSwitchingRule
00061 {
00063     static const int DSR_TYPE_TO_DST;
00065     static const int DSR_TYPE_TO_NORMAL;
00067     int type;
00069     int month;
00071     int weekDay;
00078     int week;
00080     int hour;
00082     int minute;
00084     int second;
00085 };
00086 
00093 class TimeZone
00094 {
00095     protected:
00097         int offset;
00099         bool useDST;
00101         DSTSwitchingRule toDST;
00103         DSTSwitchingRule toNormal;
00105         std::string nameNormal;
00107         std::string nameDST;
00109         std::string shortNameNormal;
00111         std::string shortNameDST;
00113         std::string aliases;
00114         
00115     public:
00117         static const DSTSwitchingRule DSR_TO_DST_EUROPE_WESTERN;
00119         static const DSTSwitchingRule DSR_TO_NORMAL_EUROPE_WESTERN;
00121         static const DSTSwitchingRule DSR_TO_DST_EUROPE_CENTRAL;
00123         static const DSTSwitchingRule DSR_TO_NORMAL_EUROPE_CENTRAL;
00125         static const DSTSwitchingRule DSR_TO_DST_EUROPE_EASTERN;
00127         static const DSTSwitchingRule DSR_TO_NORMAL_EUROPE_EASTERN;
00129         static const DSTSwitchingRule DSR_TO_DST_USA;
00131         static const DSTSwitchingRule DSR_TO_NORMAL_USA;
00133         static const DSTSwitchingRule DSR_TO_DST_EGYPT;
00135         static const DSTSwitchingRule DSR_TO_NORMAL_EGYPT;
00136         
00141         TimeZone();
00142         
00149         TimeZone(int initOffset);
00150         
00162         TimeZone(int initOffset,
00163             const std::string &initNameNormal, 
00164             const std::string &initNameDST,
00165             const std::string &initShortNameNormal, 
00166             const std::string &initShortNameDST, 
00167             const std::string &initAliases);
00168         
00177         TimeZone(int initOffset, 
00178             const DSTSwitchingRule &initToDST, 
00179             const DSTSwitchingRule &initToNormal);
00180         
00194         TimeZone(int initOffset, 
00195             const DSTSwitchingRule &initToDST, 
00196             const DSTSwitchingRule &initToNormal, 
00197             const std::string &initNameNormal, 
00198             const std::string &initNameDST,
00199             const std::string &initShortNameNormal, 
00200             const std::string &initShortNameDST, 
00201             const std::string &initAliases);
00202         
00207         virtual ~TimeZone();
00208         
00215         virtual void setOffset(int newOffset);
00216         
00224         virtual void setNameNormal(const std::string &newNameNormal);
00225         
00233         virtual void setNameDST(const std::string &newNameDST);
00234         
00242         virtual void setShortNameNormal(const std::string &newNameNormal);
00243         
00250         virtual void setShortNameDST(const std::string &newNameDST);
00251         
00264         virtual void setAliases(const std::string &newAliases);
00265         
00273         virtual void setDSTRules(const DSTSwitchingRule &newToDST, 
00274             const DSTSwitchingRule &newToNormal);
00275         
00289         virtual bool isDST(const DateTime &utcDT) const;
00290         
00311         virtual bool localIsDST(const DateTime &localDT) const;
00312         
00326         virtual int getCurrentOffset(const DateTime &utcDT) const;
00327         
00338         virtual const DSTSwitchingRule *getDSTRule(bool ruleFlag) const;
00339         
00350         DateTime getSwitchDT(Year year, const DSTSwitchingRule &rule) const;
00351         
00356         virtual int getOffset() const;
00357         
00362         virtual std::string getNameNormal() const;
00363         
00368         virtual std::string getNameDST() const;
00369         
00374         virtual std::string getShortNameNormal() const;
00375         
00380         virtual std::string getShortNameDST() const;
00381         
00387         virtual std::string getAliases() const;
00388         
00396         virtual bool hasAlias(const std::string &checkAlias) const;
00397         
00406         virtual void enableDST(bool enableFlag);
00407 };
00408 
00409 }
00410 
00411 }
00412 
00416 #endif

Generated on Tue Mar 14 20:58:30 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6