comparison 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
comparison
equal deleted inserted replaced
2474:0c57f40e2fbf 2475:8cc3ca64a534
559 #endif 559 #endif
560 return s; 560 return s;
561 } 561 }
562 562
563 563
564 std::string SystemToolbox::GetNowIsoString() 564 static boost::posix_time::ptime GetNow(bool utc)
565 { 565 {
566 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); 566 if (utc)
567 return boost::posix_time::to_iso_string(now); 567 {
568 return boost::posix_time::second_clock::universal_time();
569 }
570 else
571 {
572 return boost::posix_time::second_clock::local_time();
573 }
574 }
575
576
577 std::string SystemToolbox::GetNowIsoString(bool utc)
578 {
579 return boost::posix_time::to_iso_string(GetNow(utc));
568 } 580 }
569 581
570 582
571 void SystemToolbox::GetNowDicom(std::string& date, 583 void SystemToolbox::GetNowDicom(std::string& date,
572 std::string& time) 584 std::string& time,
573 { 585 bool utc)
574 boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); 586 {
587 boost::posix_time::ptime now = GetNow(utc);
575 tm tm = boost::posix_time::to_tm(now); 588 tm tm = boost::posix_time::to_tm(now);
576 589
577 char s[32]; 590 char s[32];
578 sprintf(s, "%04d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); 591 sprintf(s, "%04d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
579 date.assign(s); 592 date.assign(s);