00001
00002
00003
00004
00005
00006
00007
00008 #ifndef BOOSTER_LOCALE_DATE_TIME_FACET_H_INCLUDED
00009 #define BOOSTER_LOCALE_DATE_TIME_FACET_H_INCLUDED
00010
00011 #include <booster/config.h>
00012 #ifdef BOOSTER_MSVC
00013 # pragma warning(push)
00014 # pragma warning(disable : 4275 4251 4231 4660)
00015 #endif
00016
00017 #include <booster/cstdint.h>
00018 #include <locale>
00019
00020 namespace booster {
00021 namespace locale {
00025 namespace period {
00029 namespace marks {
00031 enum period_mark {
00032 invalid,
00033 era,
00034 year,
00035 extended_year,
00036 month,
00037 day,
00038 day_of_year,
00039 day_of_week,
00040
00041
00042
00043
00044 day_of_week_in_month,
00045
00046 day_of_week_local,
00047 hour,
00048 hour_12,
00049 am_pm,
00050 minute,
00051 second,
00052 week_of_year,
00053 week_of_month,
00054 first_day_of_week,
00055 };
00056
00057 }
00058
00070 class period_type {
00071 public:
00075 period_type(marks::period_mark m = marks::invalid) : mark_(m)
00076 {
00077 }
00078
00082 marks::period_mark mark() const
00083 {
00084 return mark_;
00085 }
00086
00090 bool operator==(period_type const &other) const
00091 {
00092 return mark()==other.mark();
00093 }
00097 bool operator!=(period_type const &other) const
00098 {
00099 return mark()!=other.mark();
00100 }
00101 private:
00102 marks::period_mark mark_;
00103 };
00104
00105 }
00106
00111 struct posix_time {
00112 int64_t seconds;
00113 uint32_t nanoseconds;
00114 };
00115
00121
00122 class abstract_calendar {
00123 public:
00124
00128 typedef enum {
00129 absolute_minimum,
00130 actual_minimum,
00131 greatest_minimum,
00132 current,
00133 least_maximum,
00134
00135 actual_maximum,
00136 absolute_maximum,
00137 } value_type;
00138
00142 typedef enum {
00143 move,
00144 roll,
00145 } update_type;
00146
00150 typedef enum {
00151 is_gregorian,
00152 is_dst
00153 } calendar_option_type;
00154
00158 virtual abstract_calendar *clone() const = 0;
00159
00170 virtual void set_value(period::marks::period_mark p,int value) = 0;
00171
00175 virtual void normalize() = 0;
00176
00180 virtual int get_value(period::marks::period_mark p,value_type v) const = 0;
00181
00185 virtual void set_time(posix_time const &p) = 0;
00189 virtual posix_time get_time() const = 0;
00190
00194 virtual void set_option(calendar_option_type opt,int v) = 0;
00198 virtual int get_option(calendar_option_type opt) const = 0;
00199
00204 virtual void adjust_value(period::marks::period_mark p,update_type u,int difference) = 0;
00205
00209 virtual int difference(abstract_calendar const *other,period::marks::period_mark p) const = 0;
00210
00214 virtual void set_timezone(std::string const &tz) = 0;
00218 virtual std::string get_timezone() const = 0;
00219
00223 virtual bool same(abstract_calendar const *other) const = 0;
00224
00225 virtual ~abstract_calendar()
00226 {
00227 }
00228
00229 };
00230
00234 class BOOSTER_API calendar_facet : public std::locale::facet {
00235 public:
00239 calendar_facet(size_t refs = 0) : std::locale::facet(refs)
00240 {
00241 }
00245 virtual abstract_calendar *create_calendar() const = 0;
00246
00250 static std::locale::id id;
00251 };
00252
00253 }
00254 }
00255
00256 #ifdef BOOSTER_MSVC
00257 #pragma warning(pop)
00258 #endif
00259
00260
00261 #endif
00262
00263