bigbiff | 7b4c7a6 | 2015-01-01 19:44:14 -0500 | [diff] [blame^] | 1 | /*** |
| 2 | First set of functions in this file are part of systemd, and were |
| 3 | copied to util-linux at August 2013. |
| 4 | |
| 5 | Copyright 2010 Lennart Poettering |
| 6 | Copyright (C) 2014 Karel Zak <kzak@redhat.com> |
| 7 | |
| 8 | systemd is free software; you can redistribute it and/or modify it |
| 9 | under the terms of the GNU Lesser General Public License as published by |
| 10 | the Free Software Foundation; either version 2.1 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | systemd is distributed in the hope that it will be useful, but |
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | Lesser General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Lesser General Public License |
| 19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
| 20 | ***/ |
| 21 | #ifndef UTIL_LINUX_TIME_UTIL_H |
| 22 | #define UTIL_LINUX_TIME_UTIL_H |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <inttypes.h> |
| 26 | |
| 27 | typedef uint64_t usec_t; |
| 28 | typedef uint64_t nsec_t; |
| 29 | |
| 30 | #define MSEC_PER_SEC 1000ULL |
| 31 | #define USEC_PER_SEC 1000000ULL |
| 32 | #define USEC_PER_MSEC 1000ULL |
| 33 | #define NSEC_PER_SEC 1000000000ULL |
| 34 | #define NSEC_PER_MSEC 1000000ULL |
| 35 | #define NSEC_PER_USEC 1000ULL |
| 36 | |
| 37 | #define USEC_PER_MINUTE (60ULL*USEC_PER_SEC) |
| 38 | #define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC) |
| 39 | #define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE) |
| 40 | #define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE) |
| 41 | #define USEC_PER_DAY (24ULL*USEC_PER_HOUR) |
| 42 | #define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR) |
| 43 | #define USEC_PER_WEEK (7ULL*USEC_PER_DAY) |
| 44 | #define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY) |
| 45 | #define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC) |
| 46 | #define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC) |
| 47 | #define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC) |
| 48 | #define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC) |
| 49 | |
| 50 | #define FORMAT_TIMESTAMP_MAX ((4*4+1)+11+9+4+1) /* weekdays can be unicode */ |
| 51 | #define FORMAT_TIMESTAMP_RELATIVE_MAX 256 |
| 52 | #define FORMAT_TIMESPAN_MAX 64 |
| 53 | |
| 54 | int parse_timestamp(const char *t, usec_t *usec); |
| 55 | |
| 56 | #endif /* UTIL_LINUX_TIME_UTIL_H */ |