Changeset 1430
- Timestamp:
- Dec 17, 2011, 2:48:11 AM (11 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/main_utility.cc
r1319 r1430 27 27 #include "utility.h" 28 28 29 #include "yat/utility.h" 30 29 31 #include <cctype> 30 32 #include <cassert> … … 46 48 if (verbose) 47 49 std::cout << "Reading configuration file: `" << file << "'\n"; 48 try { 50 try { 49 51 config.load(is); 50 52 } … … 70 72 typedef SVNlog::container::const_iterator LogIterator; 71 73 for (LogIterator i=log.commits().begin(); i!=log.commits().end(); ++i){ 72 time_t sec = str2time(i->date()); 73 tm* timeinfo = gmtime(&sec); 74 // grep everything prior first '-' 75 std::string year = i->date().substr(0,i->date().find('-')); 76 using yat::utility::convert; 74 77 // ignore commits in repository not present in wc 75 year2rev[ timeinfo->tm_year] = std::min(i->revision(),76 tree.last_changed_rev());78 year2rev[convert<int>(year)-1900] = std::min(i->revision(), 79 tree.last_changed_rev()); 77 80 } 78 81 -
trunk/lib/utility.cc
r1425 r1430 343 343 } 344 344 345 time_t str2time(const std::string& str)346 {347 // str in format 2006-09-09T10:55:52.132733Z348 std::stringstream sstream(str);349 time_t rawtime;350 struct tm * timeinfo;351 time ( &rawtime );352 timeinfo = gmtime ( &rawtime );353 354 unsigned int year, month, day, hour, minute, second;355 std::string tmp;356 getline(sstream,tmp,'-');357 year=atoi(tmp.c_str());358 timeinfo->tm_year = year - 1900;359 360 getline(sstream,tmp,'-');361 month=atoi(tmp.c_str());362 timeinfo->tm_mon = month - 1;363 364 getline(sstream,tmp,'T');365 day=atoi(tmp.c_str());366 timeinfo->tm_mday = day;367 368 getline(sstream,tmp,':');369 hour=atoi(tmp.c_str());370 timeinfo->tm_hour = hour;371 372 getline(sstream,tmp,':');373 minute=atoi(tmp.c_str());374 timeinfo->tm_min = minute;375 376 getline(sstream,tmp,'.');377 second=atoi(tmp.c_str());378 timeinfo->tm_sec = second;379 380 return mktime(timeinfo);381 }382 383 345 384 346 std::string match(std::string::const_iterator& first, -
trunk/lib/utility.h
r1423 r1430 220 220 { return std::search(first, last, str.begin(), str.end()); } 221 221 222 ///223 ///224 ///225 time_t str2time(const std::string&);226 227 222 /** 228 223 same as sum(3) but using binary(result, *first) rather than
Note: See TracChangeset
for help on using the changeset viewer.