mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Added a workaround for a problem in MSVC when using large years in Time::formatted
This commit is contained in:
parent
deae885df4
commit
f5ee78595a
1 changed files with 13 additions and 7 deletions
|
|
@ -136,17 +136,23 @@ namespace TimeHelpers
|
|||
typedef CharPointer_UTF32 StringType;
|
||||
#endif
|
||||
|
||||
#ifdef JUCE_MSVC
|
||||
if (tm->tm_year < -1900 || tm->tm_year > 8099)
|
||||
return String(); // Visual Studio's library can only handle 0 -> 9999 AD
|
||||
#endif
|
||||
|
||||
for (size_t bufferSize = 256; ; bufferSize += 256)
|
||||
{
|
||||
HeapBlock<StringType::CharType> buffer (bufferSize);
|
||||
|
||||
#if JUCE_ANDROID
|
||||
const size_t numChars = strftime (buffer, bufferSize - 1, format.toUTF8(), tm);
|
||||
#elif JUCE_WINDOWS
|
||||
const size_t numChars = wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm);
|
||||
#else
|
||||
const size_t numChars = wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm);
|
||||
#endif
|
||||
const size_t numChars =
|
||||
#if JUCE_ANDROID
|
||||
strftime (buffer, bufferSize - 1, format.toUTF8(), tm);
|
||||
#elif JUCE_WINDOWS
|
||||
wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm);
|
||||
#else
|
||||
wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm);
|
||||
#endif
|
||||
|
||||
if (numChars > 0 || format.isEmpty())
|
||||
return String (StringType (buffer),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue