| 19 | namespace mitk |
| 20 | { |
| 21 | std::chrono::sys_time<std::chrono::milliseconds> |
| 22 | ConvertOFDateTimeToTimePoint(const OFDateTime& time) |
| 23 | { |
| 24 | using namespace std::chrono; |
| 25 | |
| 26 | const year_month_day ymd{ |
| 27 | year{static_cast<int>(time.getDate().getYear())}, |
| 28 | month{static_cast<unsigned>(time.getDate().getMonth())}, |
| 29 | day{static_cast<unsigned>(time.getDate().getDay())}}; |
| 30 | |
| 31 | auto tp = sys_days{ymd} |
| 32 | + hours{time.getTime().getHour()} |
| 33 | + minutes{time.getTime().getMinute()} |
| 34 | + seconds{time.getTime().getIntSecond()} |
| 35 | + milliseconds{time.getTime().getMilliSecond()}; |
| 36 | |
| 37 | // A DICOM DT may carry an explicit UTC offset (&ZZXX). When present, |
| 38 | // normalize the broken-down local time to UTC so a difference taken |
| 39 | // against another OFDateTime is offset-consistent (e.g. an injection |
| 40 | // (0018,1078) stamped "+0100" differenced against an offset-less |
| 41 | // reference time). DCMTK reports an absent offset as "unspecified"; |
| 42 | // in that case leave the value as-is, which keeps the common |
| 43 | // single-timezone path bit-identical to before (two offset-less |
| 44 | // stamps still difference correctly). |
| 45 | if (time.getTime().hasTimeZone()) |
| 46 | { |
| 47 | const double tzHours = time.getTime().getTimeZone(); |
| 48 | tp -= milliseconds{std::llround(tzHours * 3600.0 * 1000.0)}; |
| 49 | } |
| 50 | |
| 51 | return tp; |
| 52 | } |
| 53 | |
| 54 | double ComputeMiliSecDuration(const OFDateTime& start, const OFDateTime& stop) |
| 55 | { |
no test coverage detected