FUNCTION::CTIME(3stap)

πŸ’– FUNCTION::CTIME πŸ’–

okay bestie, so this is a page out of the Time utility functions tapset in 3stap, and it's literally just about turning raw epoch seconds into a date a human can actually read. no cap. let's get into it πŸ•°οΈβœ¨


✨ NAME ✨

function::ctime β€” Convert seconds since epoch into human readable date/time string


πŸŽ€ SYNOPSIS πŸŽ€

1) ctime:string(epochsecs:long)

2) ctime:string()

two flavors, babe. one takes an argument, one doesn't. pick your fighter πŸ’…


🌸 ARGUMENTS 🌸

  • epochsecs β€” Number of seconds since epoch (as returned by gettimeofday_s). that's it, that's the whole arg 🫢

πŸ¦‹ DESCRIPTION πŸ¦‹

  1. Takes an argument of seconds since the epoch as returned by gettimeofday_s. Returns a string of the form:
"Wed Jun 30 21:49:08 1993"
  1. The no-arg version is the same idea, just vibing without you handing it a number.

The string will always be exactly 24 characters. no more, no less, it's giving consistent. πŸ’…

⚠️ okay so heads up: if the time would be unreasonable far in the past β€” like, before what can be represented with a 32 bit offset in seconds from the epoch β€” an error will occur. and if the time would be unreasonable far in the future, an error will also occur. you can dodge the past one with try/catch if you're built different like that. 😭

Note that the epoch (zero) corresponds to:

"Thu Jan 1 00:00:00 1970"

The earliest full date given by ctime, corresponding to epochsecs -2147483648, is:

"Fri Dec 13 20:45:52 1901"

The latest full date given by ctime, corresponding to epochsecs 2147483647, is:

"Tue Jan 19 03:14:07 2038"

those two are the actual edges of the 32-bit universe, bestie. it's giving bookends. πŸ“šβœ¨

The abbreviations for the days of the week are β€˜Sun’, β€˜Mon’, β€˜Tue’, β€˜Wed’, β€˜Thu’, β€˜Fri’, and β€˜Sat’. The abbreviations for the months are β€˜Jan’, β€˜Feb’, β€˜Mar’, β€˜Apr’, β€˜May’, β€˜Jun’, β€˜Jul’, β€˜Aug’, β€˜Sep’, β€˜Oct’, β€˜Nov’, and β€˜Dec’.

Note that the real C library ctime function puts a newline ('\n') character at the end of the string that this function does not. so like, don't go comparing them and being confused, they are not the same girl. πŸ™ˆ

Also note that since the kernel has no concept of timezones, the returned time is always in GMT. every time. no exceptions. periodt. 🌍


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie, you ate that πŸ’– go convert some seconds into a cute little string and live your main character era. no notes. πŸ¦‹

SystemTap Tapset Reference β€” Version and date check: September 2026, so this page is lowkey iconic and also very much from the future. mwah πŸ’…πŸŽ€

πŸ“¦ where this page comes from