Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
datetime.h
1 /***************************************************************************
2  copyright : (C) 2002-2008 by Stefano Barbato
3  email : stefano@codesink.org
4 
5  $Id: datetime.h,v 1.13 2008-10-07 11:06:26 tat Exp $
6  ***************************************************************************/
7 #ifndef _MIMETIC_RFC822_DATETIME_H
8 #define _MIMETIC_RFC822_DATETIME_H
9 #include <string>
10 #include <iostream>
11 #include <mimetic/strutils.h>
12 #include <mimetic/rfc822/fieldvalue.h>
13 
14 namespace mimetic
15 {
16 
17 
18 /// RFC822 DateTime field representation
19 struct DateTime: public FieldValue
20 {
21  struct DayOfWeek {
22  enum DayName { mnShort = 0, mnLong = 1 };
23  DayOfWeek(int iDayOfWeek);
24  DayOfWeek(const std::string&);
25  bool operator==(const std::string&);
26  bool operator==(int iDayOfWeek);
27  std::string name(bool longName = false) const;
28  short ordinal() const;
29  private:
30  static const char *ms_label[][2];
31  short m_iDayOfWeek;
32  };
33  struct Month {
34  enum MonthName { mnShort = 0, mnLong = 1 };
35  Month(int iMonth);
36  Month(const std::string& );
37  bool operator==(const std::string& ) const;
38  bool operator==(int iMonth) const;
39  std::string name(bool longName = false) const;
40  short ordinal() const;
41  private:
42  static const char *ms_label[][2];
43  short m_iMonth;
44  };
45  struct Zone {
46  Zone(int iZone);
47  Zone(const std::string& );
48  bool operator==(const std::string&);
49  bool operator==(int iZone);
50  std::string name() const;
51  short ordinal() const;
52  private:
53  static int ms_offset[];
54  static const char *ms_label[];
55  short m_iZone, m_iZoneIdx;
56  std::string m_sZone;
57  };
58 
59  // DateTime
60  enum {
61  Jan = 1, Feb, Mar, Apr, May, Jun, Jul,
62  Aug, Sep, Oct, Nov, Dec
63  };
64  enum {
65  Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun
66  };
67 
68  enum {
69  GMT = +000,
70  UT = +000,
71  BST = +100,
72  CET = +100,
73  MET = +100,
74  EET = +200,
75  IST = +200,
76  METDST= +200,
77  EDT = -400,
78  CDT = -500,
79  EST = -500,
80  CST = -600,
81  MDT = -600,
82  MST = -700,
83  PDT = -700,
84  HKT = +800,
85  PST = -800,
86  JST = +900
87  };
88  DateTime();
89  DateTime(const char*);
90  DateTime(const std::string&);
91  DayOfWeek dayOfWeek() const;
92  short day() const;
93  Month month() const;
94  short year() const;
95  short hour() const;
96  short minute() const;
97  short second() const;
98  Zone zone() const;
99  std::string str() const;
100  friend std::ostream& operator<<(std::ostream&, const DateTime&);
101 protected:
102  FieldValue* clone() const;
103 private:
104  void set(const std::string&);
105  mutable int m_iDayOfWeek;
106  int m_iDay, m_iMonth, m_iYear;
107  int m_iHour, m_iMinute, m_iSecond;
108  std::string m_zone;
109 };
110 
111 
112 }
113 
114 #endif
RFC822 DateTime field representation.
Definition: datetime.h:19
Value of an header field (base class)
Definition: fieldvalue.h:17