Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

time.HolidayRule.h

00001 /*----------------------------------------------------------------------------
00002   SWORD 2000 - Software With Objects for Rapid Development
00003   Copyright (C) 2003 Eric NICOLAS
00004   ----------------------------------------------------------------------------
00005   SWORD is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU Lesser General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   SWORD is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public License
00016   along with SWORD; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018   --------------------------------------------------------------------------*/
00019 #ifndef _SWORD_TIME_HOLIDAYRULE_
00020 #define _SWORD_TIME_HOLIDAYRULE_
00021 
00022 #include "sword/time.Time.h"
00023 #include "sword/time.Date.h"
00024 
00025 int hr_parse(void *obj);
00026 
00027 namespace sword {
00028 
00030 
00091   class SWORDDECL HolidayRule {
00092     friend int ::hr_parse(void *obj);
00093   public:
00095     HolidayRule(const std::string &name, const std::string &rule);
00096 
00098     std::string toString() const;
00099 
00101 
00106     bool compute(word year, Time &time) const;
00107 
00108   private:
00109     // rule name
00110     std::string name_;
00111 
00112     // parsed rule content
00113     // :: dowo = dayOfWeekOffset
00114     word dowoNumber_;     // 0=none
00115     word dowoDay_;        // 0=sun, 1=mon...
00116     word dowoDirection_;  // 0=before, 1=after
00117     // :: do   = dayOffset
00118     word doNumber_;       // 0=none
00119     word doDirection_;    // 0=before, 1=after
00120     // :: ar   = absoluteRule
00121     word arDay_;          // 0=none (used special), otherwise 1-based
00122     word arMonth_;        // 0=none (used special), otherwise 1-based
00123     word arYear_;         // 0=none
00124     word arSpecial_;      // 0=none, 1=easter_western,  2=easter_orhtodox
00125                           //         3=vernal_equinox,  4=automnal_equinox
00126                           //         5=summer_solstice, 6=winter_solstice
00127                           //         7=chinese_newyear
00128     word arDowFilter_;    // 7=none, 0=sun, 1=mon...
00129     // :: apr  = applicationRange
00130     Time fromTime_;       // range limit
00131     Time toTime_;         // range limit
00132   };
00133 
00134   // Exceptions
00135   class HolidayRuleParsingException : public Exception {};
00136 
00137 } // namespace sword
00138 
00139 #endif // _SWORD_TIME_HOLIDAYRULE_

Generated on Tue Dec 23 20:08:56 2003 for SWORD by doxygen1.3-rc2