Bob Beck | 6cda656 | 2022-11-23 10:02:08 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2022, Google Inc. |
| 2 | * |
| 3 | * Permission to use, copy, modify, and/or distribute this software for any |
| 4 | * purpose with or without fee is hereby granted, provided that the above |
| 5 | * copyright notice and this permission notice appear in all copies. |
| 6 | * |
| 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 10 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 12 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 13 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ |
| 14 | |
| 15 | #ifndef OPENSSL_HEADER_TIME_H |
| 16 | #define OPENSSL_HEADER_TIME_H |
| 17 | |
| 18 | #include <openssl/base.h> |
| 19 | |
| 20 | #include <time.h> |
| 21 | |
| 22 | #if defined(__cplusplus) |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | // OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must |
| 27 | // be in the range of year 0000 to 9999, to a broken out time value in |tm|. It |
| 28 | // returns one on success and zero on error. |
| 29 | OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm); |
| 30 | |
| 31 | // OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in |
| 32 | // |tm| to a POSIX time value in |out|. One is returned on success, zero is |
| 33 | // returned on failure. It is a failure if |tm| contains out of range values. |
| 34 | OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out); |
| 35 | |
| 36 | |
| 37 | #if defined(__cplusplus) |
| 38 | } // extern C |
| 39 | #endif |
| 40 | |
| 41 | #endif // OPENSSL_HEADER_TIME_H |