BSON_APPEND_TIMEVAL(3)

✨ BSON_APPEND_TIMEVAL ✨

okay so bestie, this one's a libbson function and it's literally the glow-up for people who live in struct timeval land instead of millisecond land πŸ’…

🌸 SYNOPSIS 🌸

#define BSON_APPEND_TIMEVAL(b, key, val) \
   bson_append_timeval (b, key, (int) strlen (key), val)

bool
bson_append_timeval (bson_t *bson,
                     const char *key,
                     int key_length,
                     struct timeval *value);

πŸŽ€ PARAMETERS πŸŽ€

  • bson β€” a bson_t. that's the doc you're stuffing stuff into, main character energy 🫢
  • key β€” an ASCII C string holding the name of the field. like the little label on the thing 🏷️
  • key_length β€” the length of key in bytes, or -1 if you want it to just figure out the length with strlen(). lowkey the -1 is the lazy-girl option and we respect it 😌
  • value β€” a struct timeval. yup, the whole struct, not some sad little number πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

so bson_append_timeval() is a helper function β€” a lil bestie that does the translating for you β€” and what it takes is a struct timeval instead of milliseconds since the UNIX epoch. that's the whole vibe. no cap, that's it ✨

⭐ RETURNS ⭐

it returns true if the operation was applied successfully πŸŽ‰

heads up though: the function will fail if appending the value grows bson larger than INT32_MAX. so like, don't be out here trying to cram a whole universe into it, okay? 😭 that's the limit, fr fr πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc 🌈

2009-present, MongoDB, Inc.


and that's the whole page, bestie β€” you ate that πŸ“ this was libbson version 2.5.6, dated Oct 09, 2026, signing off with a lil sparkle πŸ§šβœ¨πŸ’…

πŸ“¦ where this page comes from