diff options
author | Stijn Buys <ingar@osirion.org> | 2011-05-09 20:22:34 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2011-05-09 20:22:34 +0000 |
commit | bb0f860989f84b901f80017ae0139a3fc0446dc1 (patch) | |
tree | 3b9ef3a5164326d2ad4b531904603ea2afdb40e3 /src/render | |
parent | 3de78ec1bef2a0274a719ea229709523650ade40 (diff) |
Refactored the sys::localtime routines.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/screenshot.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/render/screenshot.cc b/src/render/screenshot.cc index f75cbe8..9018a7d 100644 --- a/src/render/screenshot.cc +++ b/src/render/screenshot.cc @@ -68,27 +68,25 @@ void Screenshot::save() // check if the date has changed since the previous screenshot; std::stringstream filenamestr; - int day, month, year, hour, min, sec; - int date_serial; - - sys::get_datetime(year, month, day, hour, min, sec); - date_serial = (day - 1) + (month - 1) * 31 + (year - 2000) * 31 * 12; - if (current_date != date_serial) { - current_number = 0; - current_date = date_serial; - } - + int day, month, year, hour, min, sec, msec; + bool available = false; do { + sys::get_localtime(year, month, day, hour, min, sec, msec); std::stringstream filenamestr; + // screenshots directory filenamestr << filesystem::writedir() << "screenshots/"; // date - filenamestr << std::setw(4) << std::setfill('0') << year << "-"; - filenamestr << std::setw(2) << month << "-"; + filenamestr << std::setw(4) << std::setfill('0') << year << '-'; + filenamestr << std::setw(2) << month << '-'; filenamestr << std::setw(2) << day << '-'; - // sequence number - filenamestr << std::setw(4) << std::setfill('0') << current_number; + //time + filenamestr << std::setw(2) << hour << '-'; + filenamestr << std::setw(2) << min << '-'; + filenamestr << std::setw(2) << sec << '-'; + filenamestr << std::setw(2) << msec / 10; + // extension filenamestr << "." << screenshotformat->str(); @@ -100,7 +98,6 @@ void Screenshot::save() } else { available = true; } - current_number++; } while (!available); render::Image image(State::width(), State::height(), 3); |