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_POSIX_TIME_H 16 #define OPENSSL_HEADER_POSIX_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 27 // Time functions. 28 29 30 // OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must 31 // be in the range of year 0000 to 9999, to a broken out time value in |tm|. It 32 // returns one on success and zero on error. 33 OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm); 34 35 // OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in 36 // |tm| to a POSIX time value in |out|. One is returned on success, zero is 37 // returned on failure. It is a failure if |tm| contains out of range values. 38 OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out); 39 40 // OPENSSL_timegm converts a time value between the years 0 and 9999 in |tm| to 41 // a time_t value in |out|. One is returned on success, zero is returned on 42 // failure. It is a failure if the converted time can not be represented in a 43 // time_t, or if the tm contains out of range values. 44 OPENSSL_EXPORT int OPENSSL_timegm(const struct tm *tm, time_t *out); 45 46 47 #if defined(__cplusplus) 48 } // extern C 49 #endif 50 51 #endif // OPENSSL_HEADER_POSIX_TIME_H 52