SDL_DateTime(3type)

πŸ’– SDL_DateTime πŸ’–

okay bestie, so this is a page from the SDL3 DATATYPES corner of the manual, and it's all about SDL_DateTime β€” literally just a struct that holds a calendar date and time, all broken down into its components. that's it. that's the whole vibe. a lil container for your year/month/day/hour/etc. πŸŽ€


✨ NAME ✨

SDL_DateTime β€” a structure holding a calendar date and time broken down into its components. iconic, honestly.


🌈 SYNOPSIS 🌈

#include <SDL3/SDL_time.h>

typedef struct SDL_DateTime
{
    int year;                  /**< Year */
    int month;                 /**< Month [01-12] */
    int day;                   /**< Day of the month [01-31] */
    int hour;                  /**< Hour [0-23] */
    int minute;                /**< Minute [0-59] */
    int second;                /**< Seconds [0-60] */
    int nanosecond;            /**< Nanoseconds [0-999999999] */
    int day_of_week;           /**< Day of the week [0-6] (0 being Sunday) */
    int utc_offset;            /**< Seconds east of UTC */
} SDL_DateTime;

so every single field is an int, no cap. let's do a lil vibe check on each one πŸ’…

  • int year; β€” the year. just. the year. no range notes, no drama. she's simple, she's clean.
  • int month; β€” the month, and it lives in the range [01-12]. one-indexed besties, january is 1. πŸ™ˆ
  • int day; β€” day of the month, range [01-31].
  • int hour; β€” the hour, range [0-23]. 24-hour clock only, we don't do am/pm around here.
  • int minute; β€” the minute, range [0-59].
  • int second; β€” the seconds, range [0-60]. yes bestie, 60 β€” that range is giving leap-second energy, it's not a typo, that's what the manual says. πŸ‘‘
  • int nanosecond; β€” nanoseconds, range [0-999999999]. sub-second precision, we're fancy. ✨
  • int day_of_week; β€” the day of the week, range [0-6], with 0 being Sunday. so sunday is 0, monday is 1, and so on down the line.
  • int utc_offset; β€” seconds east of UTC. that's your timezone offset, measured in seconds, and it's east-positive.

πŸ¦‹ AVAILABILITY πŸ¦‹

this struct has been available since SDL 3.2.0. so if you're on anything older, sorry babe, she's not there yet. 😭


reminder bestie: those ranges are the documented ones, so keep your values inside them and don't be out here writing month = 13 and expecting the universe to fix it for you. 🫢

and that's the whole page, no notes, we ate. πŸ“

this lil datatype page comes to you from Simple Directmedia Layer, SDL 3.4.18, filed under SDL_DateTime(3type) β€” mwah, slay, bye bestie πŸ’œπŸ§š

πŸ“¦ where this page comes from