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"
17 Date::Date(const long l)
19 struct tm * p_tm = localtime(&l);
21 _month = p_tm->tm_mon + 1;
22 _year = p_tm->tm_year + 1900;
23 _hour = p_tm->tm_hour;
28 Date::Date(const string s)
30 if ((s == "now") || (s == "Now") || (s == "NOW")) {
32 struct tm * p_tm = localtime(&l);
34 _month = p_tm->tm_mon + 1;
35 _year = p_tm->tm_year + 1900;
36 _hour = p_tm->tm_hour;
42 // istringstream ist(s);
49 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
53 Date & Date::operator =(long l)
55 struct tm * p_tm = localtime(&l);
57 _month = p_tm->tm_mon + 1;
58 _year = p_tm->tm_year + 1900;
59 _hour = p_tm->tm_hour;
66 Date & Date::operator +(long l)
72 Date & Date::operator -(long l)
78 Date & Date::operator +=(long l)
84 Date & Date::operator -=(long l)
90 Date & Date::operator =(const string & s)
92 if ((s == "now") || (s == "Now") || (s == "NOW")) {
94 struct tm * p_tm = localtime(&l);
96 _month = p_tm->tm_mon + 1;
97 _year = p_tm->tm_year + 1900;
98 _hour = p_tm->tm_hour;
104 // istringstream ist(s);
111 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
117 string Date::str() const
123 sprintf(buf, "%02ld", _day);
128 sprintf(buf, "%02ld", _month);
133 sprintf(buf, "%04ld", _year);
138 sprintf(buf, "%02ld", _hour);
143 sprintf(buf, "%02ld", _min);
148 sprintf(buf, "%02ld", _sec);
154 long Date::epoch() const
158 T.tm_mon = _month - 1;
159 T.tm_year = _year - 1900;