1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 * Auteur : Ivan DUTKA-MALEN - EDF R&D
24 * Mail : mailto:ivan.dutka-malen@der.edf.fr
25 * Date : Wed Nov 26 14:11:42 2003
32 #include "Batch_Date.hxx"
37 Date::Date(const long l)
40 struct tm * p_tm = localtime(&l_t);
42 _month = p_tm->tm_mon + 1;
43 _year = p_tm->tm_year + 1900;
44 _hour = p_tm->tm_hour;
49 Date::Date(const string s)
51 if ((s == "now") || (s == "Now") || (s == "NOW")) {
54 struct tm * p_tm = localtime(&l_t);
56 _month = p_tm->tm_mon + 1;
57 _year = p_tm->tm_year + 1900;
58 _hour = p_tm->tm_hour;
64 // istringstream ist(s);
71 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
75 Date & Date::operator =(long l)
78 struct tm * p_tm = localtime(&l_t);
80 _month = p_tm->tm_mon + 1;
81 _year = p_tm->tm_year + 1900;
82 _hour = p_tm->tm_hour;
89 Date & Date::operator +(long l)
95 Date & Date::operator -(long l)
101 Date & Date::operator +=(long l)
107 Date & Date::operator -=(long l)
113 Date & Date::operator =(const string & s)
115 if ((s == "now") || (s == "Now") || (s == "NOW")) {
118 struct tm * p_tm = localtime(&l_t);
119 _day = p_tm->tm_mday;
120 _month = p_tm->tm_mon + 1;
121 _year = p_tm->tm_year + 1900;
122 _hour = p_tm->tm_hour;
128 // istringstream ist(s);
135 sscanf(s.c_str(), "%ld/%ld/%ld-%ld:%ld:%ld", &_day, &_month, &_year, &_hour, &_min, &_sec);
141 string Date::str() const
147 sprintf(buf, "%02ld", _day);
152 sprintf(buf, "%02ld", _month);
157 sprintf(buf, "%04ld", _year);
162 sprintf(buf, "%02ld", _hour);
167 sprintf(buf, "%02ld", _min);
172 sprintf(buf, "%02ld", _sec);
178 long Date::epoch() const
182 T.tm_mon = _month - 1;
183 T.tm_year = _year - 1900;