| 1 |
// Copyright (c) 2022, Google Inc. |
| 2 |
// SPDX-License-Identifier: ISC |
| 3 |
|
| 4 |
#ifndef OPENSSL_HEADER_POSIX_TIME_H |
| 5 |
#define OPENSSL_HEADER_POSIX_TIME_H |
| 6 |
|
| 7 |
#include <openssl/base.h> |
| 8 |
|
| 9 |
#include <time.h> |
| 10 |
|
| 11 |
#if defined(__cplusplus) |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
|
| 16 |
// Time functions. |
| 17 |
|
| 18 |
|
| 19 |
// OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must |
| 20 |
// be in the range of year 0000 to 9999, to a broken out time value in |tm|. It |
| 21 |
// returns one on success and zero on error. |
| 22 |
OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm); |
| 23 |
|
| 24 |
// OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in |
| 25 |
// |tm| to a POSIX time value in |out|. One is returned on success, zero is |
| 26 |
// returned on failure. It is a failure if |tm| contains out of range values. |
| 27 |
OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out); |
| 28 |
|
| 29 |
// OPENSSL_timegm converts a time value between the years 0 and 9999 in |tm| to |
| 30 |
// a time_t value in |out|. One is returned on success, zero is returned on |
| 31 |
// failure. It is a failure if the converted time can not be represented in a |
| 32 |
// time_t, or if the tm contains out of range values. |
| 33 |
OPENSSL_EXPORT int OPENSSL_timegm(const struct tm *tm, time_t *out); |
| 34 |
|
| 35 |
|
| 36 |
#if defined(__cplusplus) |
| 37 |
} // extern C |
| 38 |
#endif |
| 39 |
|
| 40 |
#endif // OPENSSL_HEADER_POSIX_TIME_H |