]> wimlib.net Git - wimlib/blob - src/timestamp.c
lz_sarray: Performance and memory usage optimizations
[wimlib] / src / timestamp.c
1 /*
2  * timestamp.c
3  */
4
5 /*
6  * Copyright (C) 2012, 2013 Eric Biggers
7  *
8  * This file is part of wimlib, a library for working with WIM files.
9  *
10  * wimlib is free software; you can redistribute it and/or modify it under the
11  * terms of the GNU General Public License as published by the Free
12  * Software Foundation; either version 3 of the License, or (at your option)
13  * any later version.
14  *
15  * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17  * A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with wimlib; if not, see http://www.gnu.org/licenses/.
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #include "wimlib/types.h"
29 #include "wimlib/timestamp.h"
30
31 #include <time.h>
32 #include <sys/time.h>
33
34 u64
35 get_wim_timestamp(void)
36 {
37         struct timeval tv;
38         gettimeofday(&tv, NULL);
39         return timeval_to_wim_timestamp(tv);
40 }
41
42 void
43 wim_timestamp_to_str(u64 timestamp, tchar *buf, size_t len)
44 {
45         struct tm tm;
46         time_t t = wim_timestamp_to_unix(timestamp);
47         gmtime_r(&t, &tm);
48         tstrftime(buf, len, T("%a %b %d %H:%M:%S %Y UTC"), &tm);
49 }
50