time: Use a function instead of properties to retrieve the system date and time locale info

This allows applications to re-query the values if the system locale is changed during runtime, and better matches the other locale functions. A note is included in the documentation mentioning that this can be slow, as it has to call into OS functions.

Also allows for the removal of the init/quit time functions, as they are no longer needed.
This commit is contained in:
Frank Praznik
2024-05-08 13:32:37 -04:00
parent e909c0360f
commit 1f43c88220
14 changed files with 119 additions and 100 deletions

View File

@@ -169,6 +169,26 @@ static int time_dateTimeUtilities(void *arg)
SDLTest_AssertPass("Call to SDL_TimeFromWindows()");
SDLTest_AssertCheck(ticks > 0 && ticks <= SDL_MAX_TIME, "Check result value, expected >0 && <=%" SDL_PRIs64 ", got: %" SDL_PRIs64, SDL_MAX_TIME, ticks);
/* Test time locale functions */
SDL_DateFormat dateFormat;
SDL_TimeFormat timeFormat;
result = SDL_GetDateTimeLocalePreferences(&dateFormat, &timeFormat);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(&dateFormat, &timeFormat)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(&dateFormat, NULL);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(&dateFormat, NULL)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(NULL, &timeFormat);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(NULL, &timeFormat)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
result = SDL_GetDateTimeLocalePreferences(NULL, NULL);
SDLTest_AssertPass("Call to SDL_GetDateTimeLocalePreferences(NULL, NULL)");
SDLTest_AssertCheck(result == 0, "Check result value, expected 0, got: %i", result);
return TEST_COMPLETED;
}