Changeset 1431
- Timestamp:
- Dec 17, 2011, 3:11:18 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Date.cc
r978 r1431 22 22 23 23 #include "Date.h" 24 25 #include "yat/utility.h" 24 26 25 27 #include <algorithm> … … 90 92 ss << " and "; 91 93 } 92 94 93 95 94 96 unsigned int day = (t1-t0)/24/60/60; … … 108 110 time_t timezone_correction = timeinfo->tm_gmtoff; 109 111 110 unsigned int year, month, day, hour, minute, second;111 112 std::string tmp; 112 113 std::getline(sstream,tmp,'-'); 113 year=atoi(tmp.c_str());114 timeinfo->tm_year = year- 1900;114 using yat::utility::convert; 115 timeinfo->tm_year = convert<unsigned int>(tmp) - 1900; 115 116 116 117 std::getline(sstream,tmp,'-'); 117 month=atoi(tmp.c_str()); 118 timeinfo->tm_mon = month - 1; 118 timeinfo->tm_mon = convert<unsigned int>(tmp) - 1; 119 119 120 120 std::getline(sstream,tmp,'T'); 121 day=atoi(tmp.c_str()); 122 timeinfo->tm_mday = day; 121 timeinfo->tm_mday = convert<unsigned int>(tmp); 123 122 124 123 std::getline(sstream,tmp,':'); 125 hour=atoi(tmp.c_str()); 126 timeinfo->tm_hour = hour; 124 timeinfo->tm_hour = convert<unsigned int>(tmp); 127 125 128 126 std::getline(sstream,tmp,':'); 129 minute=atoi(tmp.c_str()); 130 timeinfo->tm_min = minute; 127 timeinfo->tm_min = convert<unsigned int>(tmp); 131 128 132 129 std::getline(sstream,tmp,'.'); 133 second=atoi(tmp.c_str()); 134 timeinfo->tm_sec = second; 130 timeinfo->tm_sec = convert<unsigned int>(tmp); 135 131 136 132 time_ = mktime(timeinfo); … … 143 139 std::stringstream ss; 144 140 struct tm* timeinfo = std::gmtime(&time_); 145 char buffer[80]; 141 char buffer[80]; 146 142 size_t res = std::strftime(buffer, 80, format.c_str(), timeinfo); 147 143 if (!res) { … … 152 148 153 149 154 const Date& Date::operator=(const Date& rhs) 150 const Date& Date::operator=(const Date& rhs) 155 151 { 156 152 time_ = rhs.time_;
Note: See TracChangeset
for help on using the changeset viewer.