text
stringlengths
0
2.2M
0001, 01, 01, 00, 00, 00, 000, 490, 0 },
{ L_, "0001-01-01T00:00:00.00050",
0001, 01, 01, 00, 00, 00, 000, 500, 0 },
{ L_, "0001-01-01T00:00:00.00099",
0001, 01, 01, 00, 00, 00, 000, 990, 0 },
{ L_, "0001-01-01T00:00:00.9994" ,
0001, 01, 01, 00, 00, 00, 999, 400, 0 },
{ L_, "0001-01-01T00:00:00.9995" ,
0001, 01, 01, 00, 00, 00, 999, 500, 0 },
{ L_, "0001-01-01T00:00:00.9999" ,
0001, 01, 01, 00, 00, 00, 999, 900, 0 },
{ L_, "9998-12-31T23:59:60.9999" ,
9999, 01, 01, 00, 00, 00, 999, 900, 0 },
{ L_, "0001-01-01T00:00:00.9999994" ,
0001, 01, 01, 00, 00, 00, 999, 999, 0 },
{ L_, "0001-01-01T00:00:00.9999995" ,
0001, 01, 01, 00, 00, 01, 000, 000, 0 },
{ L_, "0001-01-01T00:00:00.9999999" ,
0001, 01, 01, 00, 00, 01, 000, 000, 0 },
{ L_, "9998-12-31T23:59:60.9999999" ,
9999, 01, 01, 00, 00, 01, 000, 000, 0 },
// omit fractional seconds
{ L_, "2014-12-23T12:34:45",
2014, 12, 23, 12, 34, 45, 000, 000, 0 },
{ L_, "2014-12-23T12:34:45Z",
2014, 12, 23, 12, 34, 45, 000, 000, 0 },
{ L_, "2014-12-23T12:34:45+00:30",
2014, 12, 23, 12, 34, 45, 000, 000, 30 },
{ L_, "2014-12-23T12:34:45-01:30",
2014, 12, 23, 12, 34, 45, 000, 000, -90 },
};
const int NUM_DATA = static_cast<int>(sizeof DATA / sizeof *DATA);
for (int ti = 0; ti < NUM_DATA; ++ti) {
const int LINE = DATA[ti].d_line;
const char *INPUT = DATA[ti].d_input;
const int LENGTH = static_cast<int>(bsl::strlen(INPUT));
const int YEAR = DATA[ti].d_year;
const int MONTH = DATA[ti].d_month;
const int DAY = DATA[ti].d_day;
const int HOUR = DATA[ti].d_hour;
const int MIN = DATA[ti].d_min;
const int SEC = DATA[ti].d_sec;
const int MSEC = DATA[ti].d_msec;
const int USEC = DATA[ti].d_usec;
const int OFFSET = DATA[ti].d_offset;
if (veryVerbose) { T_ P_(LINE) P(INPUT) }
bdlt::Datetime mX(XX); const bdlt::Datetime& X = mX;
bdlt::DatetimeTz mZ(ZZ); const bdlt::DatetimeTz& Z = mZ;
bdlt::DatetimeTz EXPECTED(bdlt::Datetime(YEAR,
MONTH,
DAY,
HOUR,
MIN,
SEC,
MSEC,
USEC),
OFFSET);
ASSERTV(LINE, INPUT, LENGTH,
0 == Util::parse(&mX, INPUT, LENGTH));
ASSERTV(LINE, EXPECTED, X, EXPECTED.utcDatetime() == X);
ASSERTV(LINE, INPUT, LENGTH,
0 == Util::parse(&mZ, INPUT, LENGTH));
ASSERTV(LINE, EXPECTED, Z, EXPECTED == Z);
mX = XX;
mZ = ZZ;
ASSERTV(LINE, INPUT, LENGTH,
0 == Util::parse(&mX, StrView(INPUT, LENGTH)));
ASSERTV(LINE, EXPECTED, X, EXPECTED.utcDatetime() == X);
ASSERTV(LINE, INPUT, LENGTH,
0 == Util::parse(&mZ, StrView(INPUT, LENGTH)));
ASSERTV(LINE, EXPECTED, Z, EXPECTED == Z);
}
}
if (verbose)
cout << "\nTesting zone designators that overflow a 'Datetime'."
<< endl;
{
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_offset;
} DATA[] = {