sdlxGetDateTimeLocalePreferences function time

bool sdlxGetDateTimeLocalePreferences(
  1. SdlxDateTimeLocale dateTime
)

Gets the current preferred date and time format for the system locale.

This might be a "slow" call that has to query the operating system. It's best to ask for this once and save the results. However, the preferred formats can change, usually because the user has changed a system preference outside of your program.

\param dateFormat a pointer to the SDL_DateFormat to hold the returned date format, may be NULL. \param timeFormat a pointer to the SDL_TimeFormat to hold the returned time format, may be NULL. \returns true on success or false on failure; call SDL_GetError() for more information.

\threadsafety This function is not thread safe.

\since This function is available since SDL 3.2.0.

extern SDL_DECLSPEC bool SDLCALL SDL_GetDateTimeLocalePreferences(SDL_DateFormat *dateFormat, SDL_TimeFormat *timeFormat)

Implementation

bool sdlxGetDateTimeLocalePreferences(SdlxDateTimeLocale dateTime) {
  final dateFormatPointer = ffi.calloc<Int32>();
  final timeFormatPointer = ffi.calloc<Int32>();
  final result = sdlGetDateTimeLocalePreferences(
    dateFormatPointer,
    timeFormatPointer,
  );
  if (result) {
    dateTime
      ..dateFormat = dateFormatPointer.value
      ..timeFormat = timeFormatPointer.value;
  }
  dateFormatPointer.callocFree();
  timeFormatPointer.callocFree();
  return result;
}