The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

668 lines
22KB

  1. /*
  2. ==============================================================================
  3. This file is part of the juce_core module of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. or without fee is hereby granted, provided that the above copyright notice and this
  7. permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  9. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  10. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  12. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. ------------------------------------------------------------------------------
  15. NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
  16. All other JUCE modules are covered by a dual GPL/commercial license, so if you are
  17. using any other modules, be sure to check that you also comply with their license.
  18. For more details, visit www.juce.com
  19. ==============================================================================
  20. */
  21. namespace TimeHelpers
  22. {
  23. static struct tm millisecondsToTM (const int64 jdm) noexcept
  24. {
  25. struct tm result;
  26. const int days = (int) (jdm / 86400LL);
  27. const int a = 32044 + days;
  28. const int b = (4 * a + 3) / 146097;
  29. const int c = a - (b * 146097) / 4;
  30. const int d = (4 * c + 3) / 1461;
  31. const int e = c - (d * 1461) / 4;
  32. const int m = (5 * e + 2) / 153;
  33. result.tm_mday = e - (153 * m + 2) / 5 + 1;
  34. result.tm_mon = m + 2 - 12 * (m / 10);
  35. result.tm_year = b * 100 + d - 6700 + (m / 10);
  36. result.tm_wday = (days + 1) % 7;
  37. result.tm_yday = -1;
  38. int t = (int) (jdm % 86400LL);
  39. result.tm_hour = t / 3600;
  40. t %= 3600;
  41. result.tm_min = t / 60;
  42. result.tm_sec = t % 60;
  43. result.tm_isdst = -1;
  44. return result;
  45. }
  46. static bool isBeyond1970to2030Range (const int64 seconds)
  47. {
  48. return seconds < 86400LL || seconds >= 2145916800LL;
  49. }
  50. static struct tm millisToLocal (const int64 millis) noexcept
  51. {
  52. const int64 seconds = millis / 1000;
  53. if (isBeyond1970to2030Range (seconds))
  54. {
  55. const int timeZoneAdjustment = 31536000 - (int) (Time (1971, 0, 1, 0, 0).toMilliseconds() / 1000);
  56. return millisecondsToTM (seconds + timeZoneAdjustment + 210866803200LL);
  57. }
  58. struct tm result;
  59. time_t now = static_cast<time_t> (seconds);
  60. #if JUCE_WINDOWS && JUCE_MINGW
  61. return *localtime (&now);
  62. #elif JUCE_WINDOWS
  63. if (now >= 0 && now <= 0x793406fff)
  64. localtime_s (&result, &now);
  65. else
  66. zerostruct (result);
  67. #else
  68. localtime_r (&now, &result); // more thread-safe
  69. #endif
  70. return result;
  71. }
  72. static struct tm millisToUTC (const int64 millis) noexcept
  73. {
  74. const int64 seconds = millis / 1000;
  75. if (isBeyond1970to2030Range (seconds))
  76. return millisecondsToTM (seconds + 210866803200LL);
  77. struct tm result;
  78. time_t now = static_cast<time_t> (seconds);
  79. #if JUCE_WINDOWS && JUCE_MINGW
  80. return *gmtime (&now);
  81. #elif JUCE_WINDOWS
  82. if (now >= 0 && now <= 0x793406fff)
  83. gmtime_s (&result, &now);
  84. else
  85. zerostruct (result);
  86. #else
  87. gmtime_r (&now, &result); // more thread-safe
  88. #endif
  89. return result;
  90. }
  91. static int getUTCOffsetSeconds (const int64 millis) noexcept
  92. {
  93. struct tm utc = millisToUTC (millis);
  94. utc.tm_isdst = -1; // Treat this UTC time as local to find the offset
  95. return (int) ((millis / 1000) - (int64) mktime (&utc));
  96. }
  97. static int extendedModulo (const int64 value, const int modulo) noexcept
  98. {
  99. return (int) (value >= 0 ? (value % modulo)
  100. : (value - ((value / modulo) + 1) * modulo));
  101. }
  102. static inline String formatString (const String& format, const struct tm* const tm)
  103. {
  104. #if JUCE_ANDROID
  105. typedef CharPointer_UTF8 StringType;
  106. #elif JUCE_WINDOWS
  107. typedef CharPointer_UTF16 StringType;
  108. #else
  109. typedef CharPointer_UTF32 StringType;
  110. #endif
  111. #ifdef JUCE_MSVC
  112. if (tm->tm_year < -1900 || tm->tm_year > 8099)
  113. return String(); // Visual Studio's library can only handle 0 -> 9999 AD
  114. #endif
  115. for (size_t bufferSize = 256; ; bufferSize += 256)
  116. {
  117. HeapBlock<StringType::CharType> buffer (bufferSize);
  118. const size_t numChars =
  119. #if JUCE_ANDROID
  120. strftime (buffer, bufferSize - 1, format.toUTF8(), tm);
  121. #elif JUCE_WINDOWS
  122. wcsftime (buffer, bufferSize - 1, format.toWideCharPointer(), tm);
  123. #else
  124. wcsftime (buffer, bufferSize - 1, format.toUTF32(), tm);
  125. #endif
  126. if (numChars > 0 || format.isEmpty())
  127. return String (StringType (buffer),
  128. StringType (buffer) + (int) numChars);
  129. }
  130. }
  131. static uint32 lastMSCounterValue = 0;
  132. }
  133. //==============================================================================
  134. Time::Time() noexcept
  135. : millisSinceEpoch (0)
  136. {
  137. }
  138. Time::Time (const Time& other) noexcept
  139. : millisSinceEpoch (other.millisSinceEpoch)
  140. {
  141. }
  142. Time::Time (const int64 ms) noexcept
  143. : millisSinceEpoch (ms)
  144. {
  145. }
  146. Time::Time (const int year,
  147. const int month,
  148. const int day,
  149. const int hours,
  150. const int minutes,
  151. const int seconds,
  152. const int milliseconds,
  153. const bool useLocalTime) noexcept
  154. {
  155. jassert (year > 100); // year must be a 4-digit version
  156. if (year < 1971 || year >= 2038 || ! useLocalTime)
  157. {
  158. // use extended maths for dates beyond 1970 to 2037..
  159. const int timeZoneAdjustment = useLocalTime ? (31536000 - (int) (Time (1971, 0, 1, 0, 0).toMilliseconds() / 1000))
  160. : 0;
  161. const int a = (13 - month) / 12;
  162. const int y = year + 4800 - a;
  163. const int jd = day + (153 * (month + 12 * a - 2) + 2) / 5
  164. + (y * 365) + (y / 4) - (y / 100) + (y / 400)
  165. - 32045;
  166. const int64 s = ((int64) jd) * 86400LL - 210866803200LL;
  167. millisSinceEpoch = 1000 * (s + (hours * 3600 + minutes * 60 + seconds - timeZoneAdjustment))
  168. + milliseconds;
  169. }
  170. else
  171. {
  172. struct tm t;
  173. t.tm_year = year - 1900;
  174. t.tm_mon = month;
  175. t.tm_mday = day;
  176. t.tm_hour = hours;
  177. t.tm_min = minutes;
  178. t.tm_sec = seconds;
  179. t.tm_isdst = -1;
  180. millisSinceEpoch = 1000 * (int64) mktime (&t);
  181. if (millisSinceEpoch < 0)
  182. millisSinceEpoch = 0;
  183. else
  184. millisSinceEpoch += milliseconds;
  185. }
  186. }
  187. Time::~Time() noexcept
  188. {
  189. }
  190. Time& Time::operator= (const Time& other) noexcept
  191. {
  192. millisSinceEpoch = other.millisSinceEpoch;
  193. return *this;
  194. }
  195. //==============================================================================
  196. int64 Time::currentTimeMillis() noexcept
  197. {
  198. #if JUCE_WINDOWS && ! JUCE_MINGW
  199. struct _timeb t;
  200. _ftime_s (&t);
  201. return ((int64) t.time) * 1000 + t.millitm;
  202. #else
  203. struct timeval tv;
  204. gettimeofday (&tv, nullptr);
  205. return ((int64) tv.tv_sec) * 1000 + tv.tv_usec / 1000;
  206. #endif
  207. }
  208. Time JUCE_CALLTYPE Time::getCurrentTime() noexcept
  209. {
  210. return Time (currentTimeMillis());
  211. }
  212. //==============================================================================
  213. uint32 juce_millisecondsSinceStartup() noexcept;
  214. uint32 Time::getMillisecondCounter() noexcept
  215. {
  216. const uint32 now = juce_millisecondsSinceStartup();
  217. if (now < TimeHelpers::lastMSCounterValue)
  218. {
  219. // in multi-threaded apps this might be called concurrently, so
  220. // make sure that our last counter value only increases and doesn't
  221. // go backwards..
  222. if (now < TimeHelpers::lastMSCounterValue - 1000)
  223. TimeHelpers::lastMSCounterValue = now;
  224. }
  225. else
  226. {
  227. TimeHelpers::lastMSCounterValue = now;
  228. }
  229. return now;
  230. }
  231. uint32 Time::getApproximateMillisecondCounter() noexcept
  232. {
  233. if (TimeHelpers::lastMSCounterValue == 0)
  234. getMillisecondCounter();
  235. return TimeHelpers::lastMSCounterValue;
  236. }
  237. void Time::waitForMillisecondCounter (const uint32 targetTime) noexcept
  238. {
  239. for (;;)
  240. {
  241. const uint32 now = getMillisecondCounter();
  242. if (now >= targetTime)
  243. break;
  244. const int toWait = (int) (targetTime - now);
  245. if (toWait > 2)
  246. {
  247. Thread::sleep (jmin (20, toWait >> 1));
  248. }
  249. else
  250. {
  251. // xxx should consider using mutex_pause on the mac as it apparently
  252. // makes it seem less like a spinlock and avoids lowering the thread pri.
  253. for (int i = 10; --i >= 0;)
  254. Thread::yield();
  255. }
  256. }
  257. }
  258. //==============================================================================
  259. double Time::highResolutionTicksToSeconds (const int64 ticks) noexcept
  260. {
  261. return ticks / (double) getHighResolutionTicksPerSecond();
  262. }
  263. int64 Time::secondsToHighResolutionTicks (const double seconds) noexcept
  264. {
  265. return (int64) (seconds * (double) getHighResolutionTicksPerSecond());
  266. }
  267. //==============================================================================
  268. String Time::toString (const bool includeDate,
  269. const bool includeTime,
  270. const bool includeSeconds,
  271. const bool use24HourClock) const noexcept
  272. {
  273. String result;
  274. if (includeDate)
  275. {
  276. result << getDayOfMonth() << ' '
  277. << getMonthName (true) << ' '
  278. << getYear();
  279. if (includeTime)
  280. result << ' ';
  281. }
  282. if (includeTime)
  283. {
  284. const int mins = getMinutes();
  285. result << (use24HourClock ? getHours() : getHoursInAmPmFormat())
  286. << (mins < 10 ? ":0" : ":") << mins;
  287. if (includeSeconds)
  288. {
  289. const int secs = getSeconds();
  290. result << (secs < 10 ? ":0" : ":") << secs;
  291. }
  292. if (! use24HourClock)
  293. result << (isAfternoon() ? "pm" : "am");
  294. }
  295. return result.trimEnd();
  296. }
  297. String Time::formatted (const String& format) const
  298. {
  299. struct tm t (TimeHelpers::millisToLocal (millisSinceEpoch));
  300. return TimeHelpers::formatString (format, &t);
  301. }
  302. //==============================================================================
  303. int Time::getYear() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_year + 1900; }
  304. int Time::getMonth() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mon; }
  305. int Time::getDayOfYear() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_yday; }
  306. int Time::getDayOfMonth() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_mday; }
  307. int Time::getDayOfWeek() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_wday; }
  308. int Time::getHours() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_hour; }
  309. int Time::getMinutes() const noexcept { return TimeHelpers::millisToLocal (millisSinceEpoch).tm_min; }
  310. int Time::getSeconds() const noexcept { return TimeHelpers::extendedModulo (millisSinceEpoch / 1000, 60); }
  311. int Time::getMilliseconds() const noexcept { return TimeHelpers::extendedModulo (millisSinceEpoch, 1000); }
  312. int Time::getHoursInAmPmFormat() const noexcept
  313. {
  314. const int hours = getHours();
  315. if (hours == 0) return 12;
  316. if (hours <= 12) return hours;
  317. return hours - 12;
  318. }
  319. bool Time::isAfternoon() const noexcept
  320. {
  321. return getHours() >= 12;
  322. }
  323. bool Time::isDaylightSavingTime() const noexcept
  324. {
  325. return TimeHelpers::millisToLocal (millisSinceEpoch).tm_isdst != 0;
  326. }
  327. String Time::getTimeZone() const noexcept
  328. {
  329. String zone[2];
  330. #if JUCE_MSVC
  331. _tzset();
  332. for (int i = 0; i < 2; ++i)
  333. {
  334. char name[128] = { 0 };
  335. size_t length;
  336. _get_tzname (&length, name, 127, i);
  337. zone[i] = name;
  338. }
  339. #else
  340. #if JUCE_MINGW
  341. #warning "Can't find a replacement for tzset on mingw - ideas welcome!"
  342. #else
  343. tzset();
  344. #endif
  345. const char** const zonePtr = (const char**) tzname;
  346. zone[0] = zonePtr[0];
  347. zone[1] = zonePtr[1];
  348. #endif
  349. if (isDaylightSavingTime())
  350. {
  351. zone[0] = zone[1];
  352. if (zone[0].length() > 3
  353. && zone[0].containsIgnoreCase ("daylight")
  354. && zone[0].contains ("GMT"))
  355. zone[0] = "BST";
  356. }
  357. return zone[0].substring (0, 3);
  358. }
  359. int Time::getUTCOffsetSeconds() const noexcept
  360. {
  361. return TimeHelpers::getUTCOffsetSeconds (millisSinceEpoch);
  362. }
  363. String Time::getUTCOffsetString (bool includeSemiColon) const
  364. {
  365. if (int seconds = getUTCOffsetSeconds())
  366. {
  367. const int minutes = seconds / 60;
  368. return String::formatted (includeSemiColon ? "%+03d:%02d"
  369. : "%+03d%02d",
  370. minutes / 60,
  371. minutes % 60);
  372. }
  373. return "Z";
  374. }
  375. String Time::toISO8601 (bool includeDividerCharacters) const
  376. {
  377. return String::formatted (includeDividerCharacters ? "%04d-%02d-%02dT%02d:%02d:%02.03f"
  378. : "%04d%02d%02dT%02d%02d%02.03f",
  379. getYear(),
  380. getMonth() + 1,
  381. getDayOfMonth(),
  382. getHours(),
  383. getMinutes(),
  384. getSeconds() + getMilliseconds() / 1000.0)
  385. + getUTCOffsetString (includeDividerCharacters);
  386. }
  387. static int parseFixedSizeIntAndSkip (String::CharPointerType& t, int numChars, char charToSkip) noexcept
  388. {
  389. int n = 0;
  390. for (int i = numChars; --i >= 0;)
  391. {
  392. const int digit = (int) (*t - '0');
  393. if (! isPositiveAndBelow (digit, 10))
  394. return -1;
  395. ++t;
  396. n = n * 10 + digit;
  397. }
  398. if (charToSkip != 0 && *t == (juce_wchar) charToSkip)
  399. ++t;
  400. return n;
  401. }
  402. Time Time::fromISO8601 (StringRef iso) noexcept
  403. {
  404. String::CharPointerType t = iso.text;
  405. const int year = parseFixedSizeIntAndSkip (t, 4, '-');
  406. if (year < 0)
  407. return Time();
  408. const int month = parseFixedSizeIntAndSkip (t, 2, '-');
  409. if (month < 0)
  410. return Time();
  411. const int day = parseFixedSizeIntAndSkip (t, 2, 0);
  412. if (day < 0)
  413. return Time();
  414. int hours = 0, minutes = 0, milliseconds = 0;
  415. if (*t == 'T')
  416. {
  417. ++t;
  418. hours = parseFixedSizeIntAndSkip (t, 2, ':');
  419. if (hours < 0)
  420. return Time();
  421. minutes = parseFixedSizeIntAndSkip (t, 2, ':');
  422. if (minutes < 0)
  423. return Time();
  424. milliseconds = (int) (1000.0 * CharacterFunctions::readDoubleValue (t));
  425. }
  426. const juce_wchar nextChar = t.getAndAdvance();
  427. if (nextChar == '-' || nextChar == '+')
  428. {
  429. const int offsetHours = parseFixedSizeIntAndSkip (t, 2, ':');
  430. if (offsetHours < 0)
  431. return Time();
  432. const int offsetMinutes = parseFixedSizeIntAndSkip (t, 2, 0);
  433. if (offsetMinutes < 0)
  434. return Time();
  435. const int offsetMs = (offsetHours * 60 + offsetMinutes) * 60 * 1000;
  436. milliseconds += nextChar == '-' ? offsetMs : -offsetMs; // NB: this seems backwards but is correct!
  437. }
  438. else if (nextChar != 0 && nextChar != 'Z')
  439. {
  440. return Time();
  441. }
  442. Time result (year, month - 1, day, hours, minutes, 0, 0, false);
  443. result.millisSinceEpoch += milliseconds;
  444. return result;
  445. }
  446. String Time::getMonthName (const bool threeLetterVersion) const
  447. {
  448. return getMonthName (getMonth(), threeLetterVersion);
  449. }
  450. String Time::getWeekdayName (const bool threeLetterVersion) const
  451. {
  452. return getWeekdayName (getDayOfWeek(), threeLetterVersion);
  453. }
  454. static const char* const shortMonthNames[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  455. static const char* const longMonthNames[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
  456. String Time::getMonthName (int monthNumber, const bool threeLetterVersion)
  457. {
  458. monthNumber %= 12;
  459. return TRANS (threeLetterVersion ? shortMonthNames [monthNumber]
  460. : longMonthNames [monthNumber]);
  461. }
  462. String Time::getWeekdayName (int day, const bool threeLetterVersion)
  463. {
  464. static const char* const shortDayNames[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  465. static const char* const longDayNames[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  466. day %= 7;
  467. return TRANS (threeLetterVersion ? shortDayNames [day]
  468. : longDayNames [day]);
  469. }
  470. //==============================================================================
  471. Time& Time::operator+= (RelativeTime delta) noexcept { millisSinceEpoch += delta.inMilliseconds(); return *this; }
  472. Time& Time::operator-= (RelativeTime delta) noexcept { millisSinceEpoch -= delta.inMilliseconds(); return *this; }
  473. Time operator+ (Time time, RelativeTime delta) noexcept { Time t (time); return t += delta; }
  474. Time operator- (Time time, RelativeTime delta) noexcept { Time t (time); return t -= delta; }
  475. Time operator+ (RelativeTime delta, Time time) noexcept { Time t (time); return t += delta; }
  476. const RelativeTime operator- (Time time1, Time time2) noexcept { return RelativeTime::milliseconds (time1.toMilliseconds() - time2.toMilliseconds()); }
  477. bool operator== (Time time1, Time time2) noexcept { return time1.toMilliseconds() == time2.toMilliseconds(); }
  478. bool operator!= (Time time1, Time time2) noexcept { return time1.toMilliseconds() != time2.toMilliseconds(); }
  479. bool operator< (Time time1, Time time2) noexcept { return time1.toMilliseconds() < time2.toMilliseconds(); }
  480. bool operator> (Time time1, Time time2) noexcept { return time1.toMilliseconds() > time2.toMilliseconds(); }
  481. bool operator<= (Time time1, Time time2) noexcept { return time1.toMilliseconds() <= time2.toMilliseconds(); }
  482. bool operator>= (Time time1, Time time2) noexcept { return time1.toMilliseconds() >= time2.toMilliseconds(); }
  483. static int getMonthNumberForCompileDate (const String& m) noexcept
  484. {
  485. for (int i = 0; i < 12; ++i)
  486. if (m.equalsIgnoreCase (shortMonthNames[i]))
  487. return i;
  488. // If you hit this because your compiler has an unusual __DATE__
  489. // format, let us know so we can add support for it!
  490. jassertfalse;
  491. return 0;
  492. }
  493. Time Time::getCompilationDate()
  494. {
  495. StringArray dateTokens, timeTokens;
  496. dateTokens.addTokens (__DATE__, true);
  497. dateTokens.removeEmptyStrings (true);
  498. timeTokens.addTokens (__TIME__, ":", StringRef());
  499. return Time (dateTokens[2].getIntValue(),
  500. getMonthNumberForCompileDate (dateTokens[0]),
  501. dateTokens[1].getIntValue(),
  502. timeTokens[0].getIntValue(),
  503. timeTokens[1].getIntValue());
  504. }
  505. //==============================================================================
  506. //==============================================================================
  507. #if JUCE_UNIT_TESTS
  508. class TimeTests : public UnitTest
  509. {
  510. public:
  511. TimeTests() : UnitTest ("Time") {}
  512. void runTest() override
  513. {
  514. beginTest ("Time");
  515. Time t = Time::getCurrentTime();
  516. expect (t > Time());
  517. Thread::sleep (15);
  518. expect (Time::getCurrentTime() > t);
  519. expect (t.getTimeZone().isNotEmpty());
  520. expect (t.getUTCOffsetString (true) == "Z" || t.getUTCOffsetString (true).length() == 6);
  521. expect (t.getUTCOffsetString (false) == "Z" || t.getUTCOffsetString (false).length() == 5);
  522. expect (Time::fromISO8601 (t.toISO8601 (true)) == t);
  523. expect (Time::fromISO8601 (t.toISO8601 (false)) == t);
  524. expect (Time::fromISO8601 ("2016-02-16") == Time (2016, 1, 16, 0, 0, 0, 0, false));
  525. expect (Time::fromISO8601 ("20160216Z") == Time (2016, 1, 16, 0, 0, 0, 0, false));
  526. expect (Time::fromISO8601 ("2016-02-16T15:03:57+00:00") == Time (2016, 1, 16, 15, 3, 57, 0, false));
  527. expect (Time::fromISO8601 ("20160216T150357+0000") == Time (2016, 1, 16, 15, 3, 57, 0, false));
  528. expect (Time::fromISO8601 ("2016-02-16T15:03:57.999+00:00") == Time (2016, 1, 16, 15, 3, 57, 999, false));
  529. expect (Time::fromISO8601 ("20160216T150357.999+0000") == Time (2016, 1, 16, 15, 3, 57, 999, false));
  530. expect (Time::fromISO8601 ("2016-02-16T15:03:57.999Z") == Time (2016, 1, 16, 15, 3, 57, 999, false));
  531. expect (Time::fromISO8601 ("20160216T150357.999Z") == Time (2016, 1, 16, 15, 3, 57, 999, false));
  532. expect (Time::fromISO8601 ("2016-02-16T15:03:57.999-02:30") == Time (2016, 1, 16, 17, 33, 57, 999, false));
  533. expect (Time::fromISO8601 ("20160216T150357.999-0230") == Time (2016, 1, 16, 17, 33, 57, 999, false));
  534. }
  535. };
  536. static TimeTests timeTests;
  537. #endif