2014-11-10 17:20:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkTime.h"
|
|
|
|
#include "include/private/SkTo.h"
|
|
|
|
#include "tests/Test.h"
|
2014-11-10 17:20:22 +00:00
|
|
|
|
|
|
|
DEF_TEST(Time_GetDateTime, r) {
|
|
|
|
SkTime::DateTime dateTime;
|
|
|
|
SkTime::GetDateTime(&dateTime);
|
|
|
|
|
|
|
|
// TODO(future generation): update these values.
|
2014-11-10 22:39:24 +00:00
|
|
|
const uint16_t kMinimumSaneYear = 1964;
|
2014-11-10 17:20:22 +00:00
|
|
|
const uint16_t kMaximumSaneYear = 2064;
|
2014-11-10 22:39:24 +00:00
|
|
|
|
|
|
|
if (dateTime.fYear < kMinimumSaneYear) {
|
|
|
|
ERRORF(r,
|
|
|
|
"SkTime::GetDateTime: %u (CurrentYear) < %u (MinimumSaneYear)",
|
|
|
|
static_cast<unsigned>(dateTime.fYear),
|
|
|
|
static_cast<unsigned>(kMinimumSaneYear));
|
|
|
|
}
|
|
|
|
if (dateTime.fYear > kMaximumSaneYear) {
|
|
|
|
ERRORF(r,
|
|
|
|
"SkTime::GetDateTime: %u (CurrentYear) > %u (MaximumSaneYear)",
|
|
|
|
static_cast<unsigned>(dateTime.fYear),
|
|
|
|
static_cast<unsigned>(kMaximumSaneYear));
|
|
|
|
}
|
2014-11-10 17:20:22 +00:00
|
|
|
|
|
|
|
REPORTER_ASSERT(r, dateTime.fMonth >= 1);
|
|
|
|
REPORTER_ASSERT(r, dateTime.fMonth <= 12);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(r, dateTime.fDay >= 1);
|
|
|
|
REPORTER_ASSERT(r, dateTime.fDay <= 31);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(r, dateTime.fHour <= 23);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(r, dateTime.fMinute <= 59);
|
|
|
|
|
|
|
|
REPORTER_ASSERT(r, dateTime.fSecond <= 60); // leap seconds are 23:59:60
|
2015-05-01 14:06:23 +00:00
|
|
|
|
|
|
|
// The westernmost timezone is -12:00.
|
|
|
|
// The easternmost timezone is +14:00.
|
2015-08-26 12:15:46 +00:00
|
|
|
REPORTER_ASSERT(r, SkTAbs(SkToInt(dateTime.fTimeZoneMinutes)) <= 14 * 60);
|
2015-05-01 14:06:23 +00:00
|
|
|
|
|
|
|
SkString timeStamp;
|
|
|
|
dateTime.toISO8601(&timeStamp);
|
|
|
|
REPORTER_ASSERT(r, timeStamp.size() > 0);
|
2016-02-25 01:59:16 +00:00
|
|
|
INFOF(r, "\nCurrent Time (ISO-8601 format): \"%s\"\n",
|
|
|
|
timeStamp.c_str());
|
2014-11-10 17:20:22 +00:00
|
|
|
}
|