BSON_APPEND_TIME_T(3)

πŸ’… BSON_APPEND_TIME_T πŸ’…

okay so bestie, welcome to the libbson manual page for BSON_APPEND_TIME_T(3) β€” yes that's the whole title, yes it's a lot of caps, we love her for it ✨. Pull up a chair, this one's actually a little shortcut macro and it's kind of iconic.


🌸 SYNOPSIS 🌸

here's the whole vibe, exactly as written, don't come for me:

#define BSON_APPEND_TIME_T(b, key, val) \
   bson_append_time_t (b, key, (int) strlen (key), val)

bool
bson_append_time_t (bson_t *bson,
                    const char *key,
                    int key_length,
                    time_t value);

so you've got the macro on top β€” she's the shortcut β€” and the real function underneath doing the actual work 🫢.


πŸŽ€ PARAMETERS πŸŽ€

every single one of these matters, no skipping:

  • bson β€” a bson_t. that's your doc, your canvas, your main character πŸ’–
  • key β€” an ASCII C string with the name of the field. like, what you're calling this thing
  • key_length β€” the length of key in bytes, or -1 if you want it to just figure out the length with strlen() πŸ”₯ (ngl -1 is the move most of the time)
  • value β€” a time_t. yeah. that's it. that's the value

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is the part where it gets good: the bson_append_time_t() function is a helper that takes a time_t instead of milliseconds since the UNIX epoch. that's literally the whole pitch πŸ’€ like, you've got a time_t lying around and you don't wanna do the conversion math yourself, so you hand it to her and she handles it. slay.


⭐ RETURNS ⭐

she returns true if the operation was applied successfully πŸ’š.

careful bestie β€” the function will fail if appending the value grows bson larger than INT32_MAX. that's the hard limit, no cap, she is not going past it 😭

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” periodt 🫑


2009-present, MongoDB, Inc. β€” protect her at all costs πŸ’œ


and that's the page!! shoutout to libbson version 2.5.6, dated Oct 09, 2026 β€” she's stamped, sealed, and delivered πŸŽ€βœ¨ go append some timestamps bestie, you've got this πŸ’…

πŸ“¦ where this page comes from