00001
00002
00003
00004
00005
00006
00007 #ifndef _MIMETIC_RFC822_DATETIME_H
00008 #define _MIMETIC_RFC822_DATETIME_H
00009 #include <string>
00010 #include <iostream>
00011 #include <mimetic/strutils.h>
00012 #include <mimetic/rfc822/fieldvalue.h>
00013
00014 namespace mimetic
00015 {
00016
00017
00018
00019 struct DateTime: public FieldValue
00020 {
00021 struct DayOfWeek {
00022 enum DayName { mnShort = 0, mnLong = 1 };
00023 DayOfWeek(int iDayOfWeek);
00024 DayOfWeek(const std::string&);
00025 bool operator==(const std::string&);
00026 bool operator==(int iDayOfWeek);
00027 std::string name(bool longName = false) const;
00028 short ordinal() const;
00029 private:
00030 static const char *ms_label[][2];
00031 short m_iDayOfWeek;
00032 };
00033 struct Month {
00034 enum MonthName { mnShort = 0, mnLong = 1 };
00035 Month(int iMonth);
00036 Month(const std::string& );
00037 bool operator==(const std::string& ) const;
00038 bool operator==(int iMonth) const;
00039 std::string name(bool longName = false) const;
00040 short ordinal() const;
00041 private:
00042 static const char *ms_label[][2];
00043 short m_iMonth;
00044 };
00045 struct Zone {
00046 Zone(int iZone);
00047 Zone(const std::string& );
00048 bool operator==(const std::string&);
00049 bool operator==(int iZone);
00050 std::string name() const;
00051 short ordinal() const;
00052 private:
00053 static int ms_offset[];
00054 static const char *ms_label[];
00055 short m_iZone, m_iZoneIdx;
00056 std::string m_sZone;
00057 };
00058
00059
00060 enum {
00061 Jan = 1, Feb, Mar, Apr, May, Jun, Jul,
00062 Aug, Sep, Oct, Nov, Dec
00063 };
00064 enum {
00065 Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun
00066 };
00067
00068 enum {
00069 GMT = +000,
00070 UT = +000,
00071 BST = +100,
00072 CET = +100,
00073 MET = +100,
00074 EET = +200,
00075 IST = +200,
00076 METDST= +200,
00077 EDT = -400,
00078 CDT = -500,
00079 EST = -500,
00080 CST = -600,
00081 MDT = -600,
00082 MST = -700,
00083 PDT = -700,
00084 HKT = +800,
00085 PST = -800,
00086 JST = +900
00087 };
00088 DateTime();
00089 DateTime(const char*);
00090 DateTime(const std::string&);
00091 DayOfWeek dayOfWeek() const;
00092 short day() const;
00093 Month month() const;
00094 short year() const;
00095 short hour() const;
00096 short minute() const;
00097 short second() const;
00098 Zone zone() const;
00099 std::string str() const;
00100 friend std::ostream& operator<<(std::ostream&, const DateTime&);
00101 protected:
00102 FieldValue* clone() const;
00103 private:
00104 void set(const std::string&);
00105 mutable int m_iDayOfWeek;
00106 int m_iDay, m_iMonth, m_iYear;
00107 int m_iHour, m_iMinute, m_iSecond;
00108 std::string m_zone;
00109 };
00110
00111
00112 }
00113
00114 #endif