Changeset 1bfe6f0 in nscp for include/strEx.h
- Timestamp:
- 01/17/10 12:29:46 (3 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 6822839
- Parents:
- cc2efd6
- File:
-
- 1 edited
-
include/strEx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
include/strEx.h
r753ea6d r1bfe6f0 382 382 return value * smallest_unit; 383 383 } 384 inline unsigned stoui_as_time_sec(std::wstring time, unsigned int smallest_unit = 1) { 385 std::wstring::size_type p = time.find_first_of(_T("sSmMhHdDwW")); 386 std::wstring::size_type pend = time.find_first_not_of(_T("0123456789")); 387 unsigned int value = boost::lexical_cast<unsigned int>(pend==std::wstring::npos?time:time.substr(0,pend).c_str()); 388 if (p == std::wstring::npos) 389 return value * smallest_unit; 390 else if ( (time[p] == 's') || (time[p] == 'S') ) 391 return value; 392 else if ( (time[p] == 'm') || (time[p] == 'M') ) 393 return value * 60; 394 else if ( (time[p] == 'h') || (time[p] == 'H') ) 395 return value * 60 * 60; 396 else if ( (time[p] == 'd') || (time[p] == 'D') ) 397 return value * 24 * 60 * 60; 398 else if ( (time[p] == 'w') || (time[p] == 'W') ) 399 return value * 7 * 24 * 60 * 60; 400 return value * smallest_unit; 401 } 384 402 385 403 inline unsigned long long stoi64_as_time(std::wstring time, unsigned int smallest_unit = 1000) {
Note: See TracChangeset
for help on using the changeset viewer.








