PQlocalTZInfo(3)

πŸ“¦ version 1.5.1, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– PQlocalTZInfo(3) πŸ’–

okay bestie, this one's from the libpqtypes Manual and it's literally the cutest little utility β€” it tells you what timezone the machine you're on is vibing in. no cap. πŸ•βœ¨


✨ NAME ✨

PQlocalTZInfo β€” gets the local machine's timezone information. that's it, that's the whole job, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <libpqtypes.h>

void PQlocalTZInfo(time_t *t, int *gmtoff, int *isdst, char **tzabbrp);

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, this function retrieves the local machine's timezone information. periodt. πŸ’–

If the t argument is not NULL, it represents a time_t value to get timezone information for. If it is NULL, then the current time is used instead. easy peasy πŸ“

The gmtoff argument will be pointed at the number of seconds from GMT β€” same value as the GNU (struct tm).tm_gmtoff extension. yes queen, exact same vibe πŸ‘‘

The isdst argument will be pointed at:

  • 0 if you're in standard time 🌈
  • 1 if you're in daylight savings time β˜€οΈ
  • -1 (negative one!) if it's unknown πŸ™ˆ

The tzabbrp argument will be pointed at the timezone abbreviation, like PST, ADT, EST, etc.. the little three-letter besties πŸŽ€


⭐ RETURN VALUE ⭐

None. she returns nothing, she simply is. main character energy, no receipts needed πŸ’…


πŸ”₯ EXAMPLES πŸ”₯

okay so here's a lil example that gets the local timezone information for a file's modified time. chef's kiss, ate, no crumbs:

int gmtoff;
int isdst;
char *tzabbr;
struct stat st;

stat("report.xml", &st);
PQlocalTZInfo(&st.st_mtime, &gmtoff, &isdst, &tzabbr);

πŸ’œ RATIONALE πŸ’œ

ngl, libpqtypes needs the ability to get the local machine's timezone information for the datetime data types. that was the original reason, lowkey just an internal need.

But then it later became apparent that a portable way of getting timezone information was very useful and in demand. like, everyone wanted it. so true. thus, this function was made public. she got promoted to the main roster 🫢✨


πŸ‘‘ AUTHOR πŸ‘‘

A contribution of eSilo, LLC. for the PostgreSQL Database Management System. Written by Andrew Chernow and Merlin Moncure. absolute icons, we stan πŸ’–


πŸ’€ REPORTING BUGS πŸ’€

Report bugs to <libpqtypes@esilo.com>. (be nice about it, they're doing their best πŸ₯Ί)


Copyright (c) 2011 eSilo, LLC. All rights reserved.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 😭 like literally none, zero, nada β€” don't come for them if it breaks, bestie.

🌈 SEE ALSO 🌈


mwah πŸ’‹ that's the whole page!! this was libpqtypes, dated 2011 β€” and yes, that's PQlocalTZInfo(3) herself, still serving timezone info after all these years. bye bestie, go check your gmtoff πŸ•°οΈβœ¨

πŸ“¦ where this page comes from