Mercurial > hg > orthanc
diff Core/SystemToolbox.cpp @ 2475:8cc3ca64a534
Orthanc now uses UTC (universal time) instead of local time in its database
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 19 Feb 2018 16:55:05 +0100 |
parents | 878b59270859 |
children | 2717a8872396 |
line wrap: on
line diff
--- a/Core/SystemToolbox.cpp Thu Feb 08 11:51:41 2018 +0100 +++ b/Core/SystemToolbox.cpp Mon Feb 19 16:55:05 2018 +0100 @@ -561,17 +561,30 @@ } - std::string SystemToolbox::GetNowIsoString() + static boost::posix_time::ptime GetNow(bool utc) { - boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); - return boost::posix_time::to_iso_string(now); + if (utc) + { + return boost::posix_time::second_clock::universal_time(); + } + else + { + return boost::posix_time::second_clock::local_time(); + } + } + + + std::string SystemToolbox::GetNowIsoString(bool utc) + { + return boost::posix_time::to_iso_string(GetNow(utc)); } void SystemToolbox::GetNowDicom(std::string& date, - std::string& time) + std::string& time, + bool utc) { - boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); + boost::posix_time::ptime now = GetNow(utc); tm tm = boost::posix_time::to_tm(now); char s[32];