SDL_GetDayOfYear(3)

πŸ’– SDL_GetDayOfYear πŸ’–

okay so bestie, we're in the SDL3 FUNCTIONS section of the manual and this one is literally so useful β€” it's the lil function that tells you which day of the year a calendar date lands on. yes, the "wait, is March 3rd day 62 or day 63??" question, answered. no cap. ✨


🌸 NAME 🌸

SDL_GetDayOfYear β€” get the day of year for a calendar date. that's it, that's the whole vibe πŸ—“οΈπŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_time.h>

int SDL_GetDayOfYear(int year, int month, int day);

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

three lil inputs, all of them your responsibility to get right, okay? 🫢

  • year β€” the year component of the date. the big number. the "20xx" part. πŸ‘‘
  • month β€” the month component of the date. yes you have to actually pick one, it won't guess. πŸ“
  • day β€” the day component of the date. the day-of-the-month day. not the day-of-year day. that's literally what we're computing. stay with me bestie 😭

⭐ RETURN VALUE ⭐

so here's the tea:

  • if the date is valid, you get the day of year back, and it's in the range [0-365] 🌈
  • if it's not valid, you get -1 πŸ’€ and that's your signal to call SDL_GetError() for more information.
fr fr, always check for that -1. it's giving "something went wrong" and you do NOT want to be out here treating -1 like a real day of the year. πŸ™ˆ

🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. go off, multithreaded queen. πŸ‘‘βœ¨


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. so if you're on something older... bestie. update. 😌


πŸ’– ok that's the whole page!! written by Simple Directmedia Layer for SDL 3.4.18 β€” mwah, slay, go compute some days of the year, ily, bye!! πŸŽ€πŸ¦‹πŸ’…
πŸ“¦ where this page comes from