Changeset 1430


Ignore:
Timestamp:
Dec 17, 2011, 2:48:11 AM (11 years ago)
Author:
Peter Johansson
Message:

remove str2time which was identical to Date(string) constructor

Location:
trunk/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/main_utility.cc

    r1319 r1430  
    2727#include "utility.h"
    2828
     29#include "yat/utility.h"
     30
    2931#include <cctype>
    3032#include <cassert>
     
    4648      if (verbose)
    4749        std::cout << "Reading configuration file: `" << file << "'\n";
    48       try { 
     50      try {
    4951        config.load(is);
    5052      }
     
    7072    typedef SVNlog::container::const_iterator LogIterator;
    7173    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;
    7477      // 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());
    7780    }
    7881
  • trunk/lib/utility.cc

    r1425 r1430  
    343343  }
    344344
    345   time_t str2time(const std::string& str)
    346   {
    347     //  str in format 2006-09-09T10:55:52.132733Z
    348     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 
    383345
    384346  std::string match(std::string::const_iterator& first,
  • trunk/lib/utility.h

    r1423 r1430  
    220220  { return std::search(first, last, str.begin(), str.end()); }
    221221
    222   ///
    223   ///
    224   ///
    225   time_t str2time(const std::string&);
    226 
    227222  /**
    228223     same as sum(3) but using binary(result, *first) rather than
Note: See TracChangeset for help on using the changeset viewer.