text stringlengths 0 2.2M |
|---|
// --------------------------------------------------------------------
|
if (verbose) cout << endl
|
<< "PARSE: TIME & TIMETZ" << endl
|
<< "====================" << endl;
|
char buffer[Util::k_MAX_STRLEN];
|
const bdlt::Time XX(2, 4, 6, 8); // 'XX' and 'ZZ' are controls,
|
const bdlt::TimeTz ZZ(XX, -7); // distinct from any test data
|
const int NUM_TIME_DATA = NUM_DEFAULT_TIME_DATA;
|
const DefaultTimeDataRow (&TIME_DATA)[NUM_TIME_DATA] =
|
DEFAULT_TIME_DATA;
|
const int NUM_ZONE_DATA = NUM_DEFAULT_ZONE_DATA;
|
const DefaultZoneDataRow (&ZONE_DATA)[NUM_ZONE_DATA] =
|
DEFAULT_ZONE_DATA;
|
const int NUM_CNFG_DATA = NUM_DEFAULT_CNFG_DATA;
|
const DefaultCnfgDataRow (&CNFG_DATA)[NUM_CNFG_DATA] =
|
DEFAULT_CNFG_DATA;
|
if (verbose) cout << "\nValid ISO 8601 strings." << endl;
|
for (int ti = 0; ti < NUM_TIME_DATA; ++ti) {
|
const int ILINE = TIME_DATA[ti].d_line;
|
const int HOUR = TIME_DATA[ti].d_hour;
|
const int MIN = TIME_DATA[ti].d_min;
|
const int SEC = TIME_DATA[ti].d_sec;
|
const int MSEC = TIME_DATA[ti].d_msec;
|
const int USEC = TIME_DATA[ti].d_usec;
|
for (int tj = 0; tj < NUM_ZONE_DATA; ++tj) {
|
const int JLINE = ZONE_DATA[tj].d_line;
|
const int OFFSET = ZONE_DATA[tj].d_offset;
|
if ( bdlt::Time(HOUR, MIN, SEC, MSEC, USEC) == bdlt::Time()
|
&& OFFSET != 0) {
|
continue; // skip invalid compositions
|
}
|
for (int tc = 0; tc < NUM_CNFG_DATA; ++tc) {
|
const int CLINE = CNFG_DATA[tc].d_line;
|
const bool OMITCOLON = CNFG_DATA[tc].d_omitColon;
|
const int PRECISION = CNFG_DATA[tc].d_precision;
|
const bool USECOMMA = CNFG_DATA[tc].d_useComma;
|
const bool USEZ = CNFG_DATA[tc].d_useZ;
|
int expMsec = MSEC;
|
int expUsec = USEC;
|
{
|
// adjust the expected milliseconds to account for
|
// PRECISION truncating the value generated
|
int precision = (PRECISION < 3 ? PRECISION : 3);
|
for (int i = 3; i > precision; --i) {
|
expMsec /= 10;
|
}
|
for (int i = 3; i > precision; --i) {
|
expMsec *= 10;
|
}
|
// adjust the expected microseconds to account for
|
// PRECISION truncating the value generated
|
precision = (PRECISION > 3 ? PRECISION - 3: 0);
|
for (int i = 3; i > precision; --i) {
|
expUsec /= 10;
|
}
|
for (int i = 3; i > precision; --i) {
|
expUsec *= 10;
|
}
|
}
|
const bdlt::Time TIME(HOUR, MIN, SEC, expMsec, expUsec);
|
const bdlt::TimeTz TIMETZ(TIME, OFFSET);
|
if (veryVerbose) {
|
if (0 == tc) {
|
T_ P_(ILINE) P_(JLINE) P_(TIME) P(TIMETZ);
|
}
|
T_ P_(CLINE) P_(OMITCOLON) P_(PRECISION)
|
P_(USECOMMA) P(USEZ);
|
}
|
Config mC; const Config& C = mC;
|
gg(&mC, PRECISION, OMITCOLON, USECOMMA, USEZ);
|
// without zone designator in parsed string
|
{
|
const int LENGTH = Util::generateRaw(buffer, TIME, C);
|
if (veryVerbose) {
|
const bsl::string STRING(buffer, LENGTH);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.