4 * Auteur : Ivan DUTKA-MALEN - EDF R&D
5 * Mail : mailto:ivan.dutka-malen@der.edf.fr
6 * Date : Wed Nov 26 14:11:42 2003
13 #include "Batch_Date.hxx"
18 Date::Date(const long l)
21 struct tm * p_tm = localtime(&l_t);
23 _month = p_tm->tm_mon + 1;
24 _year = p_tm->tm_year + 1900;
25 _hour = p_tm->tm_hour;
30 Date::Date(const string s)
32 if ((s == "now") || (s == "Now") || (s == "NOW")) {
35 struct tm * p_tm = localtime(&l_t);
37 _month = p_tm->tm_mon + 1;
38 _year = p_tm->tm_year + 1900;
39 _hour = p_tm->tm_hour;
45 // istringstream ist(s);
52 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
56 Date & Date::operator =(long l)
59 struct tm * p_tm = localtime(&l_t);
61 _month = p_tm->tm_mon + 1;
62 _year = p_tm->tm_year + 1900;
63 _hour = p_tm->tm_hour;
70 Date & Date::operator +(long l)
76 Date & Date::operator -(long l)
82 Date & Date::operator +=(long l)
88 Date & Date::operator -=(long l)
94 Date & Date::operator =(const string & s)
96 if ((s == "now") || (s == "Now") || (s == "NOW")) {
99 struct tm * p_tm = localtime(&l_t);
100 _day = p_tm->tm_mday;
101 _month = p_tm->tm_mon + 1;
102 _year = p_tm->tm_year + 1900;
103 _hour = p_tm->tm_hour;
109 // istringstream ist(s);
116 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
122 string Date::str() const
128 sprintf(buf, "%02ld", _day);
133 sprintf(buf, "%02ld", _month);
138 sprintf(buf, "%04ld", _year);
143 sprintf(buf, "%02ld", _hour);
148 sprintf(buf, "%02ld", _min);
153 sprintf(buf, "%02ld", _sec);
159 long Date::epoch() const
163 T.tm_mon = _month - 1;
164 T.tm_year = _year - 1900;