Exclusion: Migrated time parsing to Pig::getHMS

This commit is contained in:
Paul Beckingham 2016-04-20 17:30:21 -04:00
parent 3dc0d74082
commit 13c326070b

View file

@ -161,83 +161,29 @@ Daterange Exclusion::daterangeFromTimeBlock (
if (pig.skip ('<')) if (pig.skip ('<'))
{ {
int hh; int hh, mm, ss;
int mm; if (pig.getHMS (hh, mm, ss))
if ((pig.getDigit2 (hh) ||
pig.getDigit (hh)) &&
pig.skip (':') &&
pig.getDigit2 (mm))
{
int ss {0};
if (pig.skip (':') &&
pig.getDigit2 (ss))
{
// That's nice.
}
return Daterange (start, Datetime (start.month (), start.day (), start.year (), hh, mm, ss)); return Daterange (start, Datetime (start.month (), start.day (), start.year (), hh, mm, ss));
}
throw format ("Malformed time block '{1}'.", block); throw format ("Malformed time block '{1}'.", block);
} }
else if (pig.skip ('>')) else if (pig.skip ('>'))
{ {
int hh; int hh, mm, ss;
int mm; if (pig.getHMS (hh, mm, ss))
if ((pig.getDigit2 (hh) ||
pig.getDigit (hh)) &&
pig.skip (':') &&
pig.getDigit2 (mm))
{
int ss {0};
if (pig.skip (':') &&
pig.getDigit2 (ss))
{
// That's nice.
}
return Daterange (Datetime (start.month (), start.day (), start.year (), hh, mm, ss), end); return Daterange (Datetime (start.month (), start.day (), start.year (), hh, mm, ss), end);
}
throw format ("Malformed time block '{1}'.", block); throw format ("Malformed time block '{1}'.", block);
} }
int hh1; int hh1, mm1, ss1;
int mm1; int hh2, mm2, ss2;
if ((pig.getDigit2 (hh1) || if (pig.getHMS (hh1, mm1, ss1) &&
pig.getDigit (hh1)) && pig.skip ('-') &&
pig.skip (':') && pig.getHMS (hh2, mm2, ss2))
pig.getDigit2 (mm1)) return Daterange (
{ Datetime (start.month (), start.day (), start.year (), hh1, mm1, ss1),
int ss1 {0}; Datetime (start.month (), start.day (), start.year (), hh2, mm2, ss2));
if (pig.skip (':') &&
pig.getDigit2 (ss1))
{
// That's nice.
}
if (pig.skip ('-'))
{
int hh2;
int mm2;
if ((pig.getDigit2 (hh2) ||
pig.getDigit (hh2)) &&
pig.skip (':') &&
pig.getDigit2 (mm2))
{
int ss2 {0};
if (pig.skip (':') &&
pig.getDigit2 (ss2))
{
// That's nice.
}
return Daterange (
Datetime (start.month (), start.day (), start.year (), hh1, mm1, ss1),
Datetime (start.month (), start.day (), start.year (), hh2, mm2, ss2));
}
}
}
throw format ("Malformed time block '{1}'.", block); throw format ("Malformed time block '{1}'.", block);
} }