blob: fade4b5a3341a41377a9947ac23f6bcf85e1ca5d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
* SPDX-FileCopyrightText: 2021-2023, Alejandro Colomar <alx@kernel.org>
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
#include <string.h>
#include <time.h>
#ident "$Id$"
#include "prototypes.h"
void
date_to_str(char buf[64], long date)
{
time_t t;
const struct tm *tm;
t = date;
if (date < 0) {
strcpy(buf, "never");
return;
}
tm = gmtime(&t);
if (tm == NULL) {
strcpy(buf, "future");
return;
}
if (strftime(buf, 64, "%Y-%m-%d", tm) == 0) {
strcpy(buf, "future");
return;
}
}
|