+ Inv_Year = SHRT_MIN // should hold in wxDateTime_t
+ };
+
+ // flags for GetWeekDayName and GetMonthName
+ enum NameFlags
+ {
+ Name_Full = 0x01, // return full name
+ Name_Abbr = 0x02 // return abbreviated name
+ };
+
+ // flags for GetWeekOfYear and GetWeekOfMonth
+ enum WeekFlags
+ {
+ Default_First, // Sunday_First for US, Monday_First for the rest
+ Monday_First, // week starts with a Monday
+ Sunday_First // week starts with a Sunday
+ };
+
+ // helper classes
+ // ------------------------------------------------------------------------
+
+ // a class representing a time zone: basicly, this is just an offset
+ // (in seconds) from GMT
+ class WXDLLEXPORT TimeZone
+ {
+ public:
+ TimeZone(TZ tz);
+ TimeZone(wxDateTime_t offset = 0) { m_offset = offset; }
+
+ long GetOffset() const { return m_offset; }
+
+ private:
+ // offset for this timezone from GMT in seconds
+ long m_offset;
+ };
+
+ // standard struct tm is limited to the years from 1900 (because
+ // tm_year field is the offset from 1900), so we use our own struct
+ // instead to represent broken down time
+ //
+ // NB: this struct should always be kept normalized (i.e. mon should
+ // be < 12, 1 <= day <= 31 &c), so use AddMonths(), AddDays()
+ // instead of modifying the member fields directly!
+ struct WXDLLEXPORT Tm
+ {
+ wxDateTime_t msec, sec, min, hour, mday;
+ Month mon;
+ int year;
+
+ // default ctor inits the object to an invalid value
+ Tm();
+
+ // ctor from struct tm and the timezone
+ Tm(const struct tm& tm, const TimeZone& tz);
+
+ // check that the given date/time is valid (in Gregorian calendar)
+ bool IsValid() const;
+
+ // get the week day
+ WeekDay GetWeekDay() // not const because wday may be changed
+ {
+ if ( wday == Inv_WeekDay )
+ ComputeWeekDay();
+
+ return (WeekDay)wday;
+ }
+
+ // add the given number of months to the date keeping it normalized
+ void AddMonths(int monDiff);
+
+ // add the given number of months to the date keeping it normalized
+ void AddDays(int dayDiff);
+
+ private:
+ // compute the weekday from other fields
+ void ComputeWeekDay();
+
+ // the timezone we correspond to
+ TimeZone m_tz;
+
+ // these values can't be accessed directly because they're not always
+ // computed and we calculate them on demand
+ wxDateTime_t wday, yday;