DTSEARCHVALIDDATESTRING(3)

πŸ“¦
version 2.5.3 Β· 2 versions
, in nixos 26.05

πŸ’… DtSearchValidDateString β€” the library call that reads your messy lil date string

okay so bestie, welcome to DtSearchValidDateString, a genuine library call, and honestly it's giving "mom friend who cleans up after everyone." πŸŽ€ It takes whatever chaotic date a human typed into a free-form text field and turns it into something the machine can actually respect. Slay.


✨ SYNOPSIS ✨

like, literally just this:

#include &<Dt/Search.h>
DtSrObjdate DtSearchValidDateString(
char *date_string);

no cap, that's the whole vibe. πŸ¦‹


🌸 DESCRIPTION 🌸

DtSearchValidDateString validates a DtSearch date string β€” the kind a user might have typed into a free form text field, you know the type, "1999", "2024/07", whatever their heart desired β€” and converts it into a valid DtSrObjdate.

and here's the iconic part: an invalid date string format returns a distinctive DtSrObjdate, which means you can also use this function as a boolean test for string validity. one function, two jobs, main character energy fr fr. πŸ‘‘


🫢 ARGUMENTS 🫢

  • date_string β€” the date string to be validated and converted. yes, that's the one. that's the whole argument. πŸ’–

the format for a valid date string is "[yyyy [mm [dd]]" β€” one, two, or three ASCII numeric tokens separated by one or more nonnumeric chars (whitespace, slashes, etc). so like, flexible, but not chaotic flexible, iykyk.

  • the integer yyyy represents a Gregorian calendar year number in the range 1990 to 5995 inclusive. and listen β€” if yyyy is less than 1900, 1900 is added to it. that's the rule, that's the tea. πŸ“
  • the integer mm is a Gregorian calendar month number in the range 1 to 12 inclusive.
  • the integer dd is a Gregorian calendar day number in the range 1 to 31 inclusive.

if only two tokens are in the string, they're presumed to be yyyy and mm, and dd is presumed to be to 1. lowkey generous of it.

if only one token is in the string, it's presumed to be yyyy, and both mm and dd are presumed to be 1. it's fine, it's chill, it's defaulting. 🌈


⭐ RETURN VALUE ⭐

DtSearchValidDateString returns zero (a valid DtSrObjdate) if date_string is NULL or empty. yes bestie, nothing is also valid. πŸ’€

it returns a correctly formatted DtSrObjdate on successful parse and conversion. iconic behavior.

it returns -1 and a message on the MessageList if date_string is invalid. so when it's mad, it's communicative about it. πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹

DtSrAPI(3), DtSearchQuery(3), dtsrfzkfiles(4), DtSearch(5) β€” go read the whole friend group, they're all connected. πŸ’œ


and that's the whole page, bestie β€” no more notes, no crumbs, we ate and left zero evidence ✨ 🧚 this has been DtSearchValidDateString(library call), live from the DtSearch docs, and it's a whole library call moment β€” go validate something, periodt. πŸ’…πŸ”₯

πŸ“¦ where this page comes from