2012-08-08 09:15:34 +02:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2012-08-08 09:15:34 +02:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-01-02 20:29:24 +01:00
|
|
|
#include "TimePrint.hxx"
|
2015-08-06 22:10:25 +02:00
|
|
|
#include "client/Response.hxx"
|
2012-08-08 09:15:34 +02:00
|
|
|
|
|
|
|
void
|
2018-07-25 08:33:59 +02:00
|
|
|
time_print(Response &r, const char *name,
|
|
|
|
std::chrono::system_clock::time_point t)
|
2012-08-08 09:15:34 +02:00
|
|
|
{
|
2018-07-25 08:33:59 +02:00
|
|
|
time_t t2 = std::chrono::system_clock::to_time_t(t);
|
2017-12-12 10:22:20 +01:00
|
|
|
#ifdef _WIN32
|
2018-07-25 08:33:59 +02:00
|
|
|
const struct tm *tm2 = gmtime(&t2);
|
2012-08-08 09:15:34 +02:00
|
|
|
#else
|
|
|
|
struct tm tm;
|
2018-07-25 08:33:59 +02:00
|
|
|
const struct tm *tm2 = gmtime_r(&t2, &tm);
|
2012-08-08 09:15:34 +02:00
|
|
|
#endif
|
2013-10-19 18:19:03 +02:00
|
|
|
if (tm2 == nullptr)
|
2012-08-08 09:15:34 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
char buffer[32];
|
|
|
|
strftime(buffer, sizeof(buffer),
|
2017-12-12 10:22:20 +01:00
|
|
|
#ifdef _WIN32
|
2012-08-08 09:15:34 +02:00
|
|
|
"%Y-%m-%dT%H:%M:%SZ",
|
|
|
|
#else
|
|
|
|
"%FT%TZ",
|
|
|
|
#endif
|
|
|
|
tm2);
|
2015-08-06 22:10:25 +02:00
|
|
|
r.Format("%s: %s\n", name, buffer);
|
2012-08-08 09:15:34 +02:00
|
|
|
}
|