/[debian]/mimetic/trunk/mimetic/rfc822/datetime.h
ViewVC logotype

Contents of /mimetic/trunk/mimetic/rfc822/datetime.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 511 - (show annotations)
Sun Jan 21 20:13:31 2007 UTC (14 years, 5 months ago) by gregoa
File MIME type: text/plain
File size: 3623 byte(s)
* New upstream release.
1 /***************************************************************************
2 copyright : (C) 2002-2005 by Stefano Barbato
3 email : stefano@codesink.org
4
5 $Id: datetime.h,v 1.12 2007/01/21 14:55:34 tat Exp $
6 ***************************************************************************/
7
8 /***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16 #ifndef _MIMETIC_RFC822_DATETIME_H
17 #define _MIMETIC_RFC822_DATETIME_H
18 #include <string>
19 #include <iostream>
20 #include <mimetic/strutils.h>
21 #include <mimetic/rfc822/fieldvalue.h>
22
23 namespace mimetic
24 {
25
26
27 /// RFC822 DateTime field representation
28 struct DateTime: public FieldValue
29 {
30 struct DayOfWeek {
31 enum DayName { mnShort = 0, mnLong = 1 };
32 DayOfWeek(int iDayOfWeek);
33 DayOfWeek(const std::string&);
34 bool operator==(const std::string&);
35 bool operator==(int iDayOfWeek);
36 std::string name(bool longName = false) const;
37 short ordinal() const;
38 private:
39 static const char *ms_label[][2];
40 short m_iDayOfWeek;
41 };
42 struct Month {
43 enum MonthName { mnShort = 0, mnLong = 1 };
44 Month(int iMonth);
45 Month(const std::string& );
46 bool operator==(const std::string& ) const;
47 bool operator==(int iMonth) const;
48 std::string name(bool longName = false) const;
49 short ordinal() const;
50 private:
51 static const char *ms_label[][2];
52 short m_iMonth;
53 };
54 struct Zone {
55 Zone(int iZone);
56 Zone(const std::string& );
57 bool operator==(const std::string&);
58 bool operator==(int iZone);
59 std::string name() const;
60 short ordinal() const;
61 private:
62 static int ms_offset[];
63 static const char *ms_label[];
64 short m_iZone, m_iZoneIdx;
65 std::string m_sZone;
66 };
67
68 // DateTime
69 enum {
70 Jan = 1, Feb, Mar, Apr, May, Jun, Jul,
71 Aug, Sep, Oct, Nov, Dec
72 };
73 enum {
74 Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun
75 };
76
77 enum {
78 GMT = +000,
79 UT = +000,
80 BST = +100,
81 CET = +100,
82 MET = +100,
83 EET = +200,
84 IST = +200,
85 METDST= +200,
86 EDT = -400,
87 CDT = -500,
88 EST = -500,
89 CST = -600,
90 MDT = -600,
91 MST = -700,
92 PDT = -700,
93 HKT = +800,
94 PST = -800,
95 JST = +900
96 };
97 DateTime();
98 DateTime(const char*);
99 DateTime(const std::string&);
100 DayOfWeek dayOfWeek() const;
101 short day() const;
102 Month month() const;
103 short year() const;
104 short hour() const;
105 short minute() const;
106 short second() const;
107 Zone zone() const;
108 std::string str() const;
109 friend std::ostream& operator<<(std::ostream&, const DateTime&);
110 protected:
111 FieldValue* clone() const;
112 private:
113 void set(const std::string&);
114 mutable int m_iDayOfWeek;
115 int m_iDay, m_iMonth, m_iYear;
116 int m_iHour, m_iMinute, m_iSecond;
117 std::string m_zone;
118 };
119
120
121 }
122
123 #endif

  ViewVC Help
Powered by ViewVC 1.1.26