1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Auteur : Ivan DUTKA-MALEN - EDF R&D
26 * Mail : mailto:ivan.dutka-malen@der.edf.fr
27 * Date : Wed Nov 26 14:11:42 2003
39 Date::Date(const long l)
42 struct tm * p_tm = localtime(&l_t);
44 _month = p_tm->tm_mon + 1;
45 _year = p_tm->tm_year + 1900;
46 _hour = p_tm->tm_hour;
51 Date::Date(const string s)
53 if ((s == "now") || (s == "Now") || (s == "NOW")) {
56 struct tm * p_tm = localtime(&l_t);
58 _month = p_tm->tm_mon + 1;
59 _year = p_tm->tm_year + 1900;
60 _hour = p_tm->tm_hour;
66 // istringstream ist(s);
73 sscanf(s.c_str(), "%d/%d/%d-%d:%d:%d", &_day, &_month, &_year, &_hour, &_min, &_sec);
77 Date & Date::operator =(long l)
80 struct tm * p_tm = localtime(&l_t);
82 _month = p_tm->tm_mon + 1;
83 _year = p_tm->tm_year + 1900;
84 _hour = p_tm->tm_hour;
91 Date & Date::operator +(long l)
97 Date & Date::operator -(long l)
103 Date & Date::operator +=(long l)
109 Date & Date::operator -=(long l)
115 Date & Date::operator =(const string & s)
117 if ((s == "now") || (s == "Now") || (s == "NOW")) {
120 struct tm * p_tm = localtime(&l_t);
121 _day = p_tm->tm_mday;
122 _month = p_tm->tm_mon + 1;
123 _year = p_tm->tm_year + 1900;
124 _hour = p_tm->tm_hour;
130 // istringstream ist(s);
137 sscanf(s.c_str(), "%d/%d/%d-%d:%d:%d", &_day, &_month, &_year, &_hour, &_min, &_sec);
143 string Date::str() const
149 sprintf(buf, "%02d", _day);
154 sprintf(buf, "%02d", _month);
159 sprintf(buf, "%04d", _year);
164 sprintf(buf, "%02d", _hour);
169 sprintf(buf, "%02d", _min);
174 sprintf(buf, "%02d", _sec);
180 long Date::epoch() const
184 T.tm_mon = _month - 1;
185 T.tm_year = _year - 1900;