text stringlengths 0 2.2M |
|---|
for (int tk = 0; tk < NUM_ZONE_DATA; ++tk) {
|
const int LINE = ZONE_DATA[tk].d_line;
|
// Initialize with a *valid* datetime string, then append an
|
// invalid zone designator.
|
bsl::string bad("2010-08-17T12:26:52.726");
|
// Ensure that 'bad' is initially valid.
|
static bool firstFlag = true;
|
if (firstFlag) {
|
const char *STRING = bad.data();
|
const int LENGTH = static_cast<int>(bad.length());
|
bdlt::Datetime mD(XX); const bdlt::Datetime& D = mD;
|
ASSERT( 0 == Util::parse(&mD, STRING, LENGTH));
|
ASSERT(XX != D);
|
mD = XX;
|
ASSERT( 0 == Util::parse(&mD, StrView(STRING, LENGTH)));
|
ASSERT(XX != D);
|
}
|
// If 'ZONE_DATA[tk].d_invalid' contains nothing but digits,
|
// appending it to 'bad' simply extends the fractional second
|
// (so 'bad' remains valid).
|
if (containsOnlyDigits(ZONE_DATA[tk].d_invalid)) {
|
continue;
|
}
|
bad.append(ZONE_DATA[tk].d_invalid);
|
const char *STRING = bad.c_str();
|
const int LENGTH = static_cast<int>(bad.length());
|
if (veryVerbose) { T_ P_(LINE) P(STRING) }
|
ASSERTV(LINE, STRING, 0 != Util::parse(&mX, STRING, LENGTH));
|
ASSERTV(LINE, STRING, XX == X);
|
ASSERTV(LINE, STRING, 0 != Util::parse(&mZ, STRING, LENGTH));
|
ASSERTV(LINE, STRING, ZZ == Z);
|
ASSERTV(LINE, STRING,
|
0 != Util::parse(&mX, StrView(STRING, LENGTH)));
|
ASSERTV(LINE, STRING, XX == X);
|
ASSERTV(LINE, STRING,
|
0 != Util::parse(&mZ, StrView(STRING, LENGTH)));
|
ASSERTV(LINE, STRING, ZZ == Z);
|
}
|
}
|
if (verbose) cout << "\nTesting leap seconds and fractional seconds."
|
<< endl;
|
{
|
const struct {
|
int d_line;
|
const char *d_input;
|
int d_year;
|
int d_month;
|
int d_day;
|
int d_hour;
|
int d_min;
|
int d_sec;
|
int d_msec;
|
int d_usec;
|
int d_offset;
|
} DATA[] = {
|
// leap seconds
|
{ L_, "0001-01-01T00:00:60.000",
|
0001, 01, 01, 00, 01, 00, 000, 000, 0 },
|
{ L_, "9998-12-31T23:59:60.999",
|
9999, 01, 01, 00, 00, 00, 999, 000, 0 },
|
// fractional seconds
|
{ L_, "0001-01-01T00:00:00.0000001",
|
0001, 01, 01, 00, 00, 00, 000, 000, 0 },
|
{ L_, "0001-01-01T00:00:00.0000009",
|
0001, 01, 01, 00, 00, 00, 000, 1, 0 },
|
{ L_, "0001-01-01T00:00:00.00000001",
|
0001, 01, 01, 00, 00, 00, 000, 000, 0 },
|
{ L_, "0001-01-01T00:00:00.00000049",
|
0001, 01, 01, 00, 00, 00, 000, 000, 0 },
|
{ L_, "0001-01-01T00:00:00.00000050",
|
0001, 01, 01, 00, 00, 00, 000, 1, 0 },
|
{ L_, "0001-01-01T00:00:00.00000099",
|
0001, 01, 01, 00, 00, 00, 000, 1, 0 },
|
{ L_, "0001-01-01T00:00:00.0001",
|
0001, 01, 01, 00, 00, 00, 000, 100, 0 },
|
{ L_, "0001-01-01T00:00:00.0009",
|
0001, 01, 01, 00, 00, 00, 000, 900, 0 },
|
{ L_, "0001-01-01T00:00:00.00001",
|
0001, 01, 01, 00, 00, 00, 000, 10, 0 },
|
{ L_, "0001-01-01T00:00:00.00049",
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.