summaryrefslogtreecommitdiff
path: root/src/tag
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-07-25 08:29:55 +0200
committerMax Kellermann <max@musicpd.org>2018-07-25 08:34:52 +0200
commit517f5b19991800dcc76677234c5ffa67aca8af0e (patch)
treec89f48245747ebf1d534fd8eca17aa0ee9814232 /src/tag
parenta8ac8b25638b0dae65b8770de2725828e7372427 (diff)
util/TimeConvert: new utility library
Diffstat (limited to 'src/tag')
-rw-r--r--src/tag/Format.cxx15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/tag/Format.cxx b/src/tag/Format.cxx
index d8aa2f3f3..ab49775f0 100644
--- a/src/tag/Format.cxx
+++ b/src/tag/Format.cxx
@@ -23,6 +23,7 @@
#include "ParseName.hxx"
#include "util/format.h"
#include "util/TruncateString.hxx"
+#include "util/TimeConvert.hxx"
#include <algorithm>
@@ -86,15 +87,13 @@ TagGetter(const void *object, const char *name) noexcept
auto &ctx = const_cast<FormatTagContext &>(_ctx);
if (strcmp(name, "iso8601") == 0) {
- time_t t = time(nullptr);
-#ifdef _WIN32
- const struct tm *tm2 = gmtime(&t);
-#else
struct tm tm;
- const struct tm *tm2 = gmtime_r(&t, &tm);
-#endif
- if (tm2 == nullptr)
+
+ try {
+ tm = GmTime(std::chrono::system_clock::now());
+ } catch (...) {
return "";
+ }
strftime(ctx.buffer, sizeof(ctx.buffer),
#ifdef _WIN32
@@ -106,7 +105,7 @@ TagGetter(const void *object, const char *name) noexcept
#else
"%FT%TZ",
#endif
- tm2);
+ &tm);
return ctx.buffer;
}