OPENSSL_GMTIME(3ossl)

✨ OPENSSL_GMTIME ✨

okay bestie so this is the OPENSSL_gmtime(3ossl) page, aka the platform-agnostic OpenSSL time routines πŸ’– and yes it lives in the OpenSSL manual, we been knew.


πŸ¦‹ NAME πŸ¦‹

OPENSSL_gmtime, OPENSSL_gmtime_adj, OPENSSL_gmtime_diff β€” the platform-agnostic OpenSSL time routines, periodt. ⏰✨


🌸 SYNOPSIS 🌸

like, here's the whole vibe, copy it exactly okay:

#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 πŸ’…

so here's what each one does, no gatekeeping:

  • OPENSSL_gmtime() β€” hands you the UTC time that timer is pointing at, and drops it right into the result argument you gave it. cute, efficient, slay. 🫢
  • OPENSSL_gmtime_adj() β€” takes the offsets in offset_day and offset_sec and, like, adds them to tm. simple math bestie. βž•
  • OPENSSL_gmtime_diff() β€” does the whole calculate the difference between from and to thing. iconic behaviour honestly. πŸ”₯

πŸ‘‘ NOTES πŸ‘‘

listen up because this part is important:

calling OPENSSL_gmtime() with result equal to NULL is an error. not a vibe. don't do it. πŸ’€

the contents of the time_t given by timer get stored into the result. and if you call it with timer equal to NULL, that means use the current time. (yes, "now o'clock", we love her.) ⏳

OPENSSL_gmtime_adj() converts tm into a days-and-seconds value, adds the offsets, then converts it back into a struct tm specified by tm. leap seconds are not considered. nope, not even a little. πŸ™ˆ

OPENSSL_gmtime_diff() calculates the difference between the two struct tm structures from and to. the difference in days gets placed into *pday, and the remaining seconds go into *psec. the value in *psec will be less than the number of seconds per day (3600). leap seconds? not considered. again. πŸ•°οΈ


πŸ’œ 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. they're basically elders, and we respect them. πŸ‘‘


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>.


and that's the whole page bestie, no cap πŸ’– this was OPENSSL_GMTIME(3ossl) from OpenSSL version 3.5.9, dated 2026-09-29 β€” catch you in the group chat, mwah 🫢🌸

πŸ“¦ where this page comes from