sttime(3)

πŸ’– sttime β€” date and time handling πŸ’–

okay bestie, so this page is sttime(3), and it's genuinely so useful, i promise. it's from the ShapeTools Toolkit Library and it's all about turning strings into dates and dates back into strings. two little functions, maximum chaos potential, let's go πŸ¦‹


✨ NAME ✨

stMktime, stWriteTime β€” date and time handling. that's it, that's the whole vibe πŸŽ€


🌸 SYNOPSIS 🌸

#include <config.h>
#include <sttk.h.h>

time_tstMktime (char *string);

char*stWriteTime (time_t date);

yes the includes and the signatures are exactly like that, don't come for me, i'm just the messenger πŸ’…


🌈 DESCRIPTION 🌈

🫢 stMktime

stMktime scans the string you hand it and tries to read a date and time out of it. note the word tries β€” she's doing her best, okay 😭

she understands various formats of date strings, and here's the full list of every valid format. optional parts are in brackets, so if it's in brackets you can ghost it and she'll still understand.

  • [Tue] Jan 5[,] [19]93 β€” this one includes the standard asctime(3) format, so if you've seen that, you already know her ✨
  • Jan 5 β€” with no year given, the year defaults to the current year. she's assuming you mean now, and honestly? fair.
  • [19]93/01/05 β€” this notation requires month and day to be represented by exactly two digits. no shortcuts, no single digits, she will not be lenient πŸ’€
  • 5.1.[19]93 β€” this is the usual German notation πŸ‡©πŸ‡ͺ
  • 5.1. β€” German notation again, but referencing the current year.

so that's the date situation. now for the time ⏰

a certain time, given together with the date, must always have the following form:

  • hours:minutes[:seconds] β€” each of the fields must be an integer value within the proper range (hours: 0-23, minutes and seconds: 0-59). values below 10 may be written as one digit numbers, so 5 instead of 05 is totally fine, slay.

and here's the cute flexible part: the time value may be placed anywhere in the date string β€” at the beginning, at the end, or somewhere in the middle. main character energy, she goes wherever she wants πŸŽ€

any amount of whitespace may be given between a field of the time value and the separating colon. so 5 : 30? she'll cope. the time is always considered to be local time, no cap.

πŸ’œ stWriteTime

stWriteTime generates a time string similar to asctime(3) from its date argument. the reverse girly. iconic. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’€ BUGS πŸ’€

okay so not everything is perfect, and we're being honest here:

Time Zone Names within the time string (like MET) are not handled properly. in most cases they will cause a failure. so like… don't. πŸ™ˆ

and that's the whole page, bestie! this one's from sttk-1.7, dated Thu Jun 24 17:43:35 1993 β€” yes, she's an elder, and yes, she still ate. periodt πŸ’…βœ¨

πŸ“¦ where this page comes from