- Timestamp:
- Jan 14, 2009, 1:36:20 PM (15 years ago)
- Location:
- trunk/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Date.cc
r693 r751 4 4 Copyright (C) 2007 Peter Johansson 5 5 Copyright (C) 2008 Jari Häkkinen 6 Copyright (C) 2009 Peter Johansson 6 7 7 8 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 24 25 25 26 #include <algorithm> 27 #include <cassert> 28 #include <ctime> 26 29 #include <sstream> 27 30 #include <string> … … 29 32 namespace theplu { 30 33 namespace svndigest { 31 32 static const char* wdays_[7] = {33 "Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday",34 "Saturday"35 };36 37 38 static const char* month_[12] = {39 "January", "February", "March", "April", "May", "June", "July", "August",40 "September", "October", "November", "December"41 };42 43 34 44 35 Date::Date(void) … … 152 143 std::stringstream ss; 153 144 struct tm* timeinfo = std::gmtime(&time_); 154 for (std::string::iterator i=format.begin(); i!=format.end(); ++i) { 155 if (*i == '%' && ++i !=format.end()) { 156 if (*i == 'a') 157 ss << std::string(wdays_[timeinfo->tm_wday]).substr(0,3); 158 else if (*i == 'A') 159 ss << wdays_[timeinfo->tm_wday]; 160 else if (*i == 'b') 161 ss << std::string(month_[timeinfo->tm_mon]).substr(0,3); 162 else if (*i == 'B') 163 ss << month_[timeinfo->tm_mon]; 164 else if (*i == 'd') 165 ss << timeinfo->tm_mday; 166 else if (*i == 'e') { 167 if (timeinfo->tm_mday<10) 168 ss << "0"; 169 ss << timeinfo->tm_mday; 170 } 171 else if (*i == 'H') { 172 if (timeinfo->tm_hour<10) 173 ss << "0"; 174 ss << timeinfo->tm_hour; 175 } 176 else if (*i == 'I') { 177 int tmp = (timeinfo->tm_hour + 11) % 12 + 1; 178 if (tmp<10) 179 ss << "0"; 180 ss << tmp; 181 } 182 else if (*i == 'j') 183 ss << timeinfo->tm_yday+1; 184 else if (*i == 'm') { 185 if (timeinfo->tm_mon<9) 186 ss << "0"; 187 ss << timeinfo->tm_mon+1; 188 } 189 else if (*i == 'M') { 190 if (timeinfo->tm_min<10) 191 ss << "0"; 192 ss << timeinfo->tm_min; 193 } 194 else if (*i == 'P') 195 if (timeinfo->tm_hour<12) 196 ss << "AM"; 197 else 198 ss << "PM"; 199 else if (*i == 'S') { 200 if (timeinfo->tm_sec<10) 201 ss << "0"; 202 ss << timeinfo->tm_sec; 203 } 204 else if (*i == 'w') 205 if (timeinfo->tm_wday==0) 206 ss << "7"; 207 else 208 ss << timeinfo->tm_wday; 209 else if (*i == 'y') { 210 int y(timeinfo->tm_year % 100); 211 if (y<10) 212 ss << "0"; 213 ss << y; 214 } 215 else if (*i == 'Y') 216 ss << timeinfo->tm_year+1900; 217 else if (*i == 'Z') 218 ss << timeinfo->tm_zone; 219 else { 220 ss << '%'; 221 --i; 222 } 223 } 224 else 225 ss << *i; 226 } 227 228 return ss.str(); 145 char buffer[80]; 146 size_t res = std::strftime(buffer, 80, format.c_str(), timeinfo); 147 assert(res>0); 148 return buffer; 229 149 } 230 150 -
trunk/lib/Node.cc
r727 r751 4 4 Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson 5 5 Copyright (C) 2008 Jari Häkkinen 6 Copyright (C) 2009 Peter Johansson 6 7 7 8 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 24 25 25 26 #include "Date.h" 27 #include "HtmlStream.h" 26 28 #include "html_utility.h" 27 29 #include "SVNlog.h" … … 229 231 const SVNlog& log) const 230 232 { 233 HtmlStream hs(os); 231 234 os << "<h3>Author Summary</h3>"; 232 235 os << "<table class=\"listings\">\n"; … … 252 255 253 256 // print authors 254 const std::string timefmt("% e/%m/%y %H:%M:%S");257 const std::string timefmt("%Y-%m-%d %H:%M"); 255 258 for (std::set<std::string>::const_iterator i=stats.authors().begin(); 256 259 i!=stats.authors().end(); ++i){ … … 269 272 const Commitment& lc(log.latest_commit(*i)); 270 273 os << "</td>" << "<td>" << trac_revision(lc.revision()) 271 << "</td>" << "<td>" << Date(lc.date())(timefmt); 274 << "</td>" << "<td>"; 275 hs << Date(lc.date())(timefmt); 272 276 } 273 277 else { … … 297 301 const Commitment& lc(log.latest_commit()); 298 302 os << "<td>" << trac_revision(lc.revision()) << "</td>\n"; 299 os << "<td>" << Date(lc.date())(timefmt)<< "</td>\n"; 303 os << "<td>"; 304 hs << Date(lc.date())(timefmt); 305 os << "</td>\n"; 300 306 os << "</tr>\n"; 301 307 os << "</tbody>\n"; -
trunk/lib/first_page.cc
r693 r751 4 4 Copyright (C) 2006 Peter Johansson 5 5 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2009 Peter Johansson 6 7 7 8 This file is part of svndigest, http://dev.thep.lu.se/svndigest … … 85 86 Date begin(log.commits()[0].date()); 86 87 Date end(log.commits().back().date()); 87 std::string timefmt("%a , %e %b %Y %H:%M:%S");88 std::string timefmt("%a %b %e %H:%M:%S %Y"); 88 89 89 90 os << "<div class=\"main\">" … … 118 119 const Stats& stats) 119 120 { 121 HtmlStream hs(os); 120 122 os << "<div class=\"main\">" 121 123 << "<table class=\"main\"><thead><tr><th colspan=\"2\">" … … 130 132 <<"</tr>"; 131 133 132 std::string timefmt("%Y %b %d %H:%M:%S");134 std::string timefmt("%Y-%m-%d %H:%M"); 133 135 using namespace std; 134 136 for (vector<Commitment>::const_iterator i=lc.begin(); i!=lc.end(); ++i) { … … 145 147 << "%)</td><td>" << stats.comments(i->author()) << " (" 146 148 << 100*stats.comments(i->author())/(stats.comments()?stats.comments():1) 147 << "%)</td><td>" << Date(i->date())(timefmt) << "</td>" <<"</tr>"; 149 << "%)</td><td>"; 150 hs << Date(i->date())(timefmt); 151 os << "</td>" <<"</tr>"; 148 152 } 149 153 os << "<tr><td>Total</td>"; … … 168 172 << "<td>Removed</td><td>Message</td></tr>\n"; 169 173 HtmlStream hs(os); 170 std::string timefmt("%Y %b %d %H:%M:%S");174 std::string timefmt("%Y-%m-%d %H:%M"); 171 175 const size_t maxlength = 80; 172 176 const Configuration& conf = Configuration::instance(); … … 179 183 << "</td>"; 180 184 Date date(i->date()); 181 os << "<td>" << date(timefmt) << "</td>"; 185 os << "<td>"; 186 hs << date(timefmt); 187 os << "</td>"; 182 188 os << "<td>"; 183 189 os << trac_revision(i->revision()); -
trunk/lib/html_utility.cc
r750 r751 64 64 { 65 65 Date date; 66 os << "<p class=\"footer\">\nGenerated on " 67 << date("%a %b %d %H:%M:%S %Y") << " (UTC) by " 68 << anchor("http://dev.thep.lu.se/svndigest/", 66 HtmlStream hs(os); 67 os << "<p class=\"footer\">\nGenerated on "; 68 hs << date("%a %b %e %H:%M:%S %Y") << " (UTC) by "; 69 os << anchor("http://dev.thep.lu.se/svndigest/", 69 70 PACKAGE_STRING, 0, ""); 70 71 if (DEV_BUILD)
Note: See TracChangeset
for help on using the changeset viewer.