OPENSSL_GMTIME(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

✨ NAME ✨

Okay bestie, welcome to OPENSSL_GMTIME(3ossl) πŸ’– β€” these are OPENSSL_gmtime, OPENSSL_gmtime_adj, and OPENSSL_gmtime_diff, the platform-agnostic OpenSSL time routines. It’s giving β€œtime stuff, but portable” and honestly? slay.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openssl/crypto.h>

struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
int OPENSSL_gmtime_diff(int *pday, int *psec,
                       const struct tm *from, const struct tm *to);

πŸ’… DESCRIPTION πŸ’…

OPENSSL_gmtime() takes the UTC time specified by timer and puts it into the result argument you handed over. Very β€œhere’s your time, bestie” ✨

OPENSSL_gmtime_adj() adds the offsets in offset_day and offset_sec to tm. It’s adjusting the vibe by days and seconds, periodt πŸŽ€

OPENSSL_gmtime_diff() calculates the difference between from and to. It’s literally doing time math between two struct tms πŸ’œ


πŸŽ€ NOTES πŸŽ€

Calling OPENSSL_gmtime() with result equal to NULL is an error β€” do not do that, bestie 😭 The contents of the time_t given by timer are stored into the result. And if you call it with timer equal to NULL, that means use the current time πŸ•°οΈ

OPENSSL_gmtime_adj() converts tm into a days and seconds value, adds the offsets, then converts back into the struct tm specified by tm. Leap seconds are not considered β€” not even a little bit πŸ™ˆ

OPENSSL_gmtime_diff() calculates the difference between the two struct tm structures from and to. The difference in days is placed into *pday, and the remaining seconds are placed into *psec. The value in *psec will be less than the number of seconds per day (3600). Leap seconds are not considered here either πŸ’€


🌸 RETURN VALUES 🌸

  • OPENSSL_gmtime() β€” returns NULL on error, or result on success πŸ’–
  • OPENSSL_gmtime_adj() and OPENSSL_gmtime_diff() β€” return 0 on error, and 1 on success βœ…

πŸ’œ HISTORY πŸ’œ

OPENSSL_gmtime(), OPENSSL_gmtime_adj() and OPENSSL_gmtime_diff() have been in OpenSSL since 1.0.0. iconic behavior, no cap πŸ‘‘


Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


okay bye bestie 🫢 β€” this page is from OpenSSL 3.5.0, dated 2026-09-25, and the manual tag is OPENSSL_GMTIME(3ossl) βœ¨πŸ’–

πŸ“¦ where this page comes from