mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Exclusion: Migrated time parsing to Pig::getHMS
This commit is contained in:
parent
3dc0d74082
commit
13c326070b
1 changed files with 12 additions and 66 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue