PACS System
0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1
// BSD 3-Clause License
2
// Copyright (c) 2021-2025, 🍀☀🌕🌥 🌊
3
// See the LICENSE file in the project root for full license information.
4
27
#pragma once
28
29
#include <ctime>
30
31
namespace
kcenon::pacs::compat
{
32
43
inline
std::tm*
localtime_safe
(
const
std::time_t* time, std::tm* result) {
44
#if defined(_WIN32) || defined(_WIN64)
45
// Windows: localtime_s returns errno_t (0 on success)
46
// Parameter order: (tm*, time_t*)
47
return
localtime_s(result, time) == 0 ? result :
nullptr
;
48
#else
49
// POSIX: localtime_r returns tm* (result on success, nullptr on failure)
50
// Parameter order: (time_t*, tm*)
51
return
localtime_r(time, result);
52
#endif
53
}
54
65
inline
std::tm*
gmtime_safe
(
const
std::time_t* time, std::tm* result) {
66
#if defined(_WIN32) || defined(_WIN64)
67
// Windows: gmtime_s returns errno_t (0 on success)
68
return
gmtime_s(result, time) == 0 ? result :
nullptr
;
69
#else
70
// POSIX: gmtime_r returns tm*
71
return
gmtime_r(time, result);
72
#endif
73
}
74
75
}
// namespace kcenon::pacs::compat
kcenon::pacs::compat
Definition
factory_result.h:11
kcenon::pacs::compat::localtime_safe
std::tm * localtime_safe(const std::time_t *time, std::tm *result)
Cross-platform thread-safe local time conversion.
Definition
time.h:43
kcenon::pacs::compat::gmtime_safe
std::tm * gmtime_safe(const std::time_t *time, std::tm *result)
Cross-platform thread-safe UTC time conversion.
Definition
time.h:65
include
kcenon
pacs
compat
time.h
Generated by
1.12.0