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)
20 struct tm * p_tm = localtime(&l);
22 _month = p_tm->tm_mon + 1;
23 _year = p_tm->tm_year + 1900;
24 _hour = p_tm->tm_hour;
29 Date::Date(const string s)
31 if ((s == "now") || (s == "Now") || (s == "NOW")) {
33 struct tm * p_tm = localtime(&l);
35 _month = p_tm->tm_mon + 1;
36 _year = p_tm->tm_year + 1900;
37 _hour = p_tm->tm_hour;
43 // istringstream ist(s);
50 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
54 Date & Date::operator =(long l)
56 struct tm * p_tm = localtime(&l);
58 _month = p_tm->tm_mon + 1;
59 _year = p_tm->tm_year + 1900;
60 _hour = p_tm->tm_hour;
67 Date & Date::operator +(long l)
73 Date & Date::operator -(long l)
79 Date & Date::operator +=(long l)
85 Date & Date::operator -=(long l)
91 Date & Date::operator =(const string & s)
93 if ((s == "now") || (s == "Now") || (s == "NOW")) {
95 struct tm * p_tm = localtime(&l);
97 _month = p_tm->tm_mon + 1;
98 _year = p_tm->tm_year + 1900;
99 _hour = p_tm->tm_hour;
105 // istringstream ist(s);
112 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
118 string Date::str() const
124 sprintf(buf, "%02ld", _day);
129 sprintf(buf, "%02ld", _month);
134 sprintf(buf, "%04ld", _year);
139 sprintf(buf, "%02ld", _hour);
144 sprintf(buf, "%02ld", _min);
149 sprintf(buf, "%02ld", _sec);
155 long Date::epoch() const
159 T.tm_mon = _month - 1;
160 T.tm_year = _year - 1900;