34 dispatcher(std::time_t t): time_(t) {}
37 using namespace fmt::internal;
41 bool handle(std::tm *tm) {
return tm !=
FMT_NULL; }
44 using namespace fmt::internal;
48 bool fallback(
int res) {
return res == 0; }
52 using namespace fmt::internal;
67 inline std::tm
gmtime(std::time_t time) {
72 dispatcher(std::time_t t): time_(t) {}
75 using namespace fmt::internal;
76 return handle(
gmtime_r(&time_, &tm_));
79 bool handle(std::tm *tm) {
return tm !=
FMT_NULL; }
82 using namespace fmt::internal;
83 return fallback(
gmtime_s(&tm_, &time_));
86 bool fallback(
int res) {
return res == 0; }
105 const std::tm *time) {
109 inline std::size_t
strftime(
wchar_t *str, std::size_t count,
110 const wchar_t *
format,
const std::tm *time) {
111 return std::wcsftime(str, count, format, time);
115 template <
typename Char>
117 template <
typename ParseContext>
118 auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
119 auto it = ctx.begin();
120 if (it != ctx.end() && *it ==
':')
123 while (
end != ctx.end() && *
end !=
'}')
126 tm_format.append(it,
end);
127 tm_format.push_back(
'\0');
131 template <
typename FormatContext>
132 auto format(
const std::tm &tm, FormatContext &ctx) -> decltype(ctx.out()) {
134 std::size_t start = buf.
size();
136 std::size_t size = buf.
capacity() - start;
140 buf.
resize(start + count);
143 if (size >= tm_format.size() * 256) {
150 const std::size_t MIN_GROWTH = 10;
160 #endif // FMT_TIME_H_
std::tm gmtime(std::time_t time)
std::size_t capacity() const
std::size_t strftime(wchar_t *str, std::size_t count, const wchar_t *format, const std::tm *time)
#define FMT_END_NAMESPACE
void resize(std::size_t new_size)
std::make_unsigned< Int >::type to_unsigned(Int value)
std::basic_string< typename char_t< S >::type > format(const S &format_str, const Args &...args)
void reserve(std::size_t new_capacity)
void copy(const RangeT &range, OutputIterator out)
#define FMT_BEGIN_NAMESPACE
std::tm localtime(std::time_t time)
auto end(const C &c) -> decltype(c.end())