Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* Copyright © 2018 Red Hat, Inc |
3 |
|
|
* |
4 |
|
|
* This program is free software; you can redistribute it and/or |
5 |
|
|
* modify it under the terms of the GNU Lesser General Public |
6 |
|
|
* License as published by the Free Software Foundation; either |
7 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
8 |
|
|
* |
9 |
|
|
* This library is distributed in the hope that it will be useful, |
10 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 |
|
|
* Lesser General Public License for more details. |
13 |
|
|
* |
14 |
|
|
* You should have received a copy of the GNU Lesser General Public |
15 |
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 |
|
|
* |
17 |
|
|
* Authors: |
18 |
|
|
* Christian J. Kellner <christian@kellner.me> |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "config.h" |
22 |
|
|
|
23 |
|
|
#include "bolt-time.h" |
24 |
|
|
|
25 |
|
|
char * |
26 |
|
✗ |
bolt_epoch_format (guint64 seconds, const char *format) |
27 |
|
|
{ |
28 |
|
✗ |
g_autoptr(GDateTime) dt = NULL; |
29 |
|
|
|
30 |
|
✗ |
dt = g_date_time_new_from_unix_utc ((gint64) seconds); |
31 |
|
|
|
32 |
|
✗ |
if (dt == NULL) |
33 |
|
✗ |
return NULL; |
34 |
|
|
|
35 |
|
✗ |
return g_date_time_format (dt, format); |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
guint64 |
39 |
|
✗ |
bolt_now_in_seconds (void) |
40 |
|
|
{ |
41 |
|
✗ |
gint64 now = g_get_real_time (); |
42 |
|
|
|
43 |
|
✗ |
return (guint64) now / G_USEC_PER_SEC; |
44 |
|
|
} |
45 |
|
|
|