| 1077 | } |
| 1078 | |
| 1079 | String Utility::FormatDateTime(const char* format, double ts) |
| 1080 | { |
| 1081 | // Sub-second precision is removed, strftime() has no format specifiers for that anyway. |
| 1082 | auto tempts = boost::numeric_cast<time_t>(ts); |
| 1083 | tm tmthen; |
| 1084 | |
| 1085 | #ifdef _MSC_VER |
| 1086 | errno_t err = localtime_s(&tmthen, &tempts); |
| 1087 | if (err) { |
| 1088 | BOOST_THROW_EXCEPTION(posix_error() |
| 1089 | << boost::errinfo_api_function("localtime_s") |
| 1090 | << boost::errinfo_errno(err)); |
| 1091 | } |
| 1092 | #else /* _MSC_VER */ |
| 1093 | if (!localtime_r(&tempts, &tmthen)) { |
| 1094 | BOOST_THROW_EXCEPTION(posix_error() |
| 1095 | << boost::errinfo_api_function("localtime_r") |
| 1096 | << boost::errinfo_errno(errno)); |
| 1097 | } |
| 1098 | #endif /* _MSC_VER */ |
| 1099 | |
| 1100 | return FormatDateTime(format, &tmthen); |
| 1101 | } |
| 1102 | |
| 1103 | String Utility::FormatDateTime(const char* format, const tm* t) { |
| 1104 | /* Known limitations of the implementation: Only works if the result is at most 127 bytes, otherwise returns an |
nothing calls this directly
no test coverage detected