proxygen
Time.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
11 
13 #include <openssl/ossl_typ.h>
14 
15 namespace proxygen {
16 
17 std::string getDateTimeStr(const ASN1_TIME* const time) {
18  if (!time) {
19  return "";
20  }
21 
22  constexpr auto bufSize = 32;
23  char buf[bufSize] = {0};
24 
25  auto bio = BIO_new(BIO_s_mem());
26  if (!bio) {
27  return "";
28  }
29 
30  ASN1_TIME_print(bio, time);
31  const auto readResult = BIO_read(bio, buf, bufSize - 1);
32  BIO_free(bio);
33 
34  return ((readResult <= 0) ? "" : std::string(buf));
35 }
36 }
std::string getDateTimeStr(const ASN1_TIME *const time)
Definition: Time.cpp:17
const char * string
Definition: Conv.cpp:212
std::chrono::nanoseconds time()