// file : xsd/cxx/tree/date-time.ixx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file namespace xsd { namespace cxx { namespace tree { // time_zone // inline time_zone:: time_zone () : present_ (false) { } inline time_zone:: time_zone (short h, short m) : present_ (true), hours_ (h), minutes_ (m) { } inline bool time_zone:: zone_present () const { return present_; } inline void time_zone:: zone_reset () { present_ = false; } inline short time_zone:: zone_hours () const { return hours_; } inline void time_zone:: zone_hours (short h) { hours_ = h; present_ = true; } inline short time_zone:: zone_minutes () const { return minutes_; } inline void time_zone:: zone_minutes (short m) { minutes_ = m; present_ = true; } inline bool operator== (const time_zone& x, const time_zone& y) { return x.zone_present () ? y.zone_present () && x.zone_hours () == y.zone_hours () && x.zone_minutes () == y.zone_minutes () : !y.zone_present (); } inline bool operator!= (const time_zone& x, const time_zone& y) { return !(x == y); } // gday // template inline gday:: gday () { } template inline gday:: gday (unsigned short day) : day_ (day) { } template inline gday:: gday (unsigned short day, short zone_h, short zone_m) : time_zone (zone_h, zone_m), day_ (day) { } template inline gday:: gday (const gday& x, flags f, container* c) : B (x, f, c), time_zone (x), day_ (x.day_) { } template inline unsigned short gday:: day () const { return day_; } template inline void gday:: day (unsigned short day) { day_ = day; } template inline bool operator== (const gday& x, const gday& y) { const time_zone& xz = x; const time_zone& yz = y; return x.day () == y.day () && xz == yz; } template inline bool operator!= (const gday& x, const gday& y) { return !(x == y); } // gmonth // template inline gmonth:: gmonth () { } template inline gmonth:: gmonth (unsigned short month) : month_ (month) { } template inline gmonth:: gmonth (unsigned short month, short zone_h, short zone_m) : time_zone (zone_h, zone_m), month_ (month) { } template inline gmonth:: gmonth (const gmonth& x, flags f, container* c) : B (x, f, c), time_zone (x), month_ (x.month_) { } template inline unsigned short gmonth:: month () const { return month_; } template inline void gmonth:: month (unsigned short month) { month_ = month; } template inline bool operator== (const gmonth& x, const gmonth& y) { const time_zone& xz = x; const time_zone& yz = y; return x.month () == y.month () && xz == yz; } template inline bool operator!= (const gmonth& x, const gmonth& y) { return !(x == y); } // gyear // template inline gyear:: gyear () { } template inline gyear:: gyear (int year) : year_ (year) { } template inline gyear:: gyear (int year, short zone_h, short zone_m) : time_zone (zone_h, zone_m), year_ (year) { } template inline gyear:: gyear (const gyear& x, flags f, container* c) : B (x, f, c), time_zone (x), year_ (x.year_) { } template inline int gyear:: year () const { return year_; } template inline void gyear:: year (int year) { year_ = year; } template inline bool operator== (const gyear& x, const gyear& y) { const time_zone& xz = x; const time_zone& yz = y; return x.year () == y.year () && xz == yz; } template inline bool operator!= (const gyear& x, const gyear& y) { return !(x == y); } // gmonth_day // template inline gmonth_day:: gmonth_day () { } template inline gmonth_day:: gmonth_day (unsigned short month, unsigned short day) : month_ (month), day_ (day) { } template inline gmonth_day:: gmonth_day (unsigned short month, unsigned short day, short zone_h, short zone_m) : time_zone (zone_h, zone_m), month_ (month), day_ (day) { } template inline gmonth_day:: gmonth_day (const gmonth_day& x, flags f, container* c) : B (x, f, c), time_zone (x), month_ (x.month_), day_ (x.day_) { } template inline unsigned short gmonth_day:: month () const { return month_; } template inline void gmonth_day:: month (unsigned short month) { month_ = month; } template inline unsigned short gmonth_day:: day () const { return day_; } template inline void gmonth_day:: day (unsigned short day) { day_ = day; } template inline bool operator== (const gmonth_day& x, const gmonth_day& y) { const time_zone& xz = x; const time_zone& yz = y; return x.month () == y.month () && x.day () == y.day () && xz == yz; } template inline bool operator!= (const gmonth_day& x, const gmonth_day& y) { return !(x == y); } // gyear_month // template inline gyear_month:: gyear_month () { } template inline gyear_month:: gyear_month (int year, unsigned short month) : year_ (year), month_ (month) { } template inline gyear_month:: gyear_month (int year, unsigned short month, short zone_h, short zone_m) : time_zone (zone_h, zone_m), year_ (year), month_ (month) { } template inline gyear_month:: gyear_month (const gyear_month& x, flags f, container* c) : B (x, f, c), time_zone (x), year_ (x.year_), month_ (x.month_) { } template inline int gyear_month:: year () const { return year_; } template inline void gyear_month:: year (int year) { year_ = year; } template inline unsigned short gyear_month:: month () const { return month_; } template inline void gyear_month:: month (unsigned short month) { month_ = month; } template inline bool operator== (const gyear_month& x, const gyear_month& y) { const time_zone& xz = x; const time_zone& yz = y; return x.year () == y.year () && x.month () == y.month () && xz == yz; } template inline bool operator!= (const gyear_month& x, const gyear_month& y) { return !(x == y); } // date // template inline date:: date () { } template inline date:: date (int year, unsigned short month, unsigned short day) : year_ (year), month_ (month), day_ (day) { } template inline date:: date (int year, unsigned short month, unsigned short day, short zone_h, short zone_m) : time_zone (zone_h, zone_m), year_ (year), month_ (month), day_ (day) { } template inline date:: date (const date& x, flags f, container* c) : B (x, f, c), time_zone (x), year_ (x.year_), month_ (x.month_), day_ (x.day_) { } template inline int date:: year () const { return year_; } template inline void date:: year (int year) { year_ = year; } template inline unsigned short date:: month () const { return month_; } template inline void date:: month (unsigned short month) { month_ = month; } template inline unsigned short date:: day () const { return day_; } template inline void date:: day (unsigned short day) { day_ = day; } template inline bool operator== (const date& x, const date& y) { const time_zone& xz = x; const time_zone& yz = y; return x.year () == y.year () && x.month () == y.month () && x.day () == y.day () && xz == yz; } template inline bool operator!= (const date& x, const date& y) { return !(x == y); } // time // template inline time:: time () { } template inline time:: time (unsigned short hours, unsigned short minutes, double seconds) : hours_ (hours), minutes_ (minutes), seconds_ (seconds) { } template inline time:: time (unsigned short hours, unsigned short minutes, double seconds, short zone_h, short zone_m) : time_zone (zone_h, zone_m), hours_ (hours), minutes_ (minutes), seconds_ (seconds) { } template inline time:: time (const time& x, flags f, container* c) : B (x, f, c), time_zone (x), hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) { } template inline unsigned short time:: hours () const { return hours_; } template inline void time:: hours (unsigned short hours) { hours_ = hours; } template inline unsigned short time:: minutes () const { return minutes_; } template inline void time:: minutes (unsigned short minutes) { minutes_ = minutes; } template inline double time:: seconds () const { return seconds_; } template inline void time:: seconds (double seconds) { seconds_ = seconds; } template inline bool operator== (const time& x, const time& y) { const time_zone& xz = x; const time_zone& yz = y; return x.hours () == y.hours () && x.minutes () == y.minutes () && x.seconds () == y.seconds () && xz == yz; } template inline bool operator!= (const time& x, const time& y) { return !(x == y); } // date_time // template inline date_time:: date_time () { } template inline date_time:: date_time (int year, unsigned short month, unsigned short day, unsigned short hours, unsigned short minutes, double seconds) : year_ (year), month_ (month), day_ (day), hours_ (hours), minutes_ (minutes), seconds_ (seconds) { } template inline date_time:: date_time (int year, unsigned short month, unsigned short day, unsigned short hours, unsigned short minutes, double seconds, short zone_h, short zone_m) : time_zone (zone_h, zone_m), year_ (year), month_ (month), day_ (day), hours_ (hours), minutes_ (minutes), seconds_ (seconds) { } template inline date_time:: date_time (const date_time& x, flags f, container* c) : B (x, f, c), time_zone (x), year_ (x.year_), month_ (x.month_), day_ (x.day_), hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) { } template inline int date_time:: year () const { return year_; } template inline void date_time:: year (int year) { year_ = year; } template inline unsigned short date_time:: month () const { return month_; } template inline void date_time:: month (unsigned short month) { month_ = month; } template inline unsigned short date_time:: day () const { return day_; } template inline void date_time:: day (unsigned short day) { day_ = day; } template inline unsigned short date_time:: hours () const { return hours_; } template inline void date_time:: hours (unsigned short hours) { hours_ = hours; } template inline unsigned short date_time:: minutes () const { return minutes_; } template inline void date_time:: minutes (unsigned short minutes) { minutes_ = minutes; } template inline double date_time:: seconds () const { return seconds_; } template inline void date_time:: seconds (double seconds) { seconds_ = seconds; } template inline bool operator== (const date_time& x, const date_time& y) { const time_zone& xz = x; const time_zone& yz = y; return x.year () == y.year () && x.month () == y.month () && x.day () == y.day () && x.hours () == y.hours () && x.minutes () == y.minutes () && x.seconds () == y.seconds () && xz == yz; } template inline bool operator!= (const date_time& x, const date_time& y) { return !(x == y); } // duration // template inline duration:: duration () { } template inline duration:: duration (bool negative, unsigned int years, unsigned int months, unsigned int days, unsigned int hours, unsigned int minutes, double seconds) : negative_ (negative), years_ (years), months_ (months), days_ (days), hours_ (hours), minutes_ (minutes), seconds_ (seconds) { } template inline duration:: duration (const duration& x, flags f, container* c) : B (x, f, c), negative_ (x.negative_), years_ (x.years_), months_ (x.months_), days_ (x.days_), hours_ (x.hours_), minutes_ (x.minutes_), seconds_ (x.seconds_) { } template inline bool duration:: negative () const { return negative_; } template inline void duration:: negative (bool negative) { negative_ = negative; } template inline unsigned int duration:: years () const { return years_; } template inline void duration:: years (unsigned int years) { years_ = years; } template inline unsigned int duration:: months () const { return months_; } template inline void duration:: months (unsigned int months) { months_ = months; } template inline unsigned int duration:: days () const { return days_; } template inline void duration:: days (unsigned int days) { days_ = days; } template inline unsigned int duration:: hours () const { return hours_; } template inline void duration:: hours (unsigned int hours) { hours_ = hours; } template inline unsigned int duration:: minutes () const { return minutes_; } template inline void duration:: minutes (unsigned int minutes) { minutes_ = minutes; } template inline double duration:: seconds () const { return seconds_; } template inline void duration:: seconds (double seconds) { seconds_ = seconds; } template inline bool operator== (const duration& x, const duration& y) { return x.negative () == y.negative () && x.years () == y.years () && x.months () == y.months () && x.days () == y.days () && x.hours () == y.hours () && x.minutes () == y.minutes () && x.seconds () == y.seconds (); } template inline bool operator!= (const duration& x, const duration& y) { return !(x == y); } } } }