mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
libshared: Accomodated new argument order for Datetime
This commit is contained in:
parent
a7ffd46122
commit
24bb8ade7a
4 changed files with 20 additions and 20 deletions
|
@ -232,7 +232,7 @@ std::vector <Range> Database::segmentRange (const Range& range)
|
|||
(start_y == end_y && start_m <= end_m))
|
||||
{
|
||||
// Capture date before incrementing month.
|
||||
Datetime segmentStart (start_m, 1, start_y);
|
||||
Datetime segmentStart (start_y, start_m, 1);
|
||||
|
||||
// Next month.
|
||||
start_m += 1;
|
||||
|
@ -243,7 +243,7 @@ std::vector <Range> Database::segmentRange (const Range& range)
|
|||
}
|
||||
|
||||
// Capture date after incrementing month.
|
||||
Datetime segmentEnd (start_m, 1, start_y);
|
||||
Datetime segmentEnd (start_y, start_m, 1);
|
||||
segments.push_back (Range (segmentStart, segmentEnd));
|
||||
}
|
||||
|
||||
|
|
|
@ -42,14 +42,14 @@ void Datafile::initialize (const std::string& name)
|
|||
auto month = strtol (basename.substr (5, 2).c_str (), NULL, 10);
|
||||
|
||||
// The range is a month: [start, end).
|
||||
Datetime start (month, 1, year, 0, 0, 0);
|
||||
Datetime start (year, month, 1, 0, 0, 0);
|
||||
month++;
|
||||
if (month > 12)
|
||||
{
|
||||
year++;
|
||||
month = 1;
|
||||
}
|
||||
Datetime end (month, 1, year, 0, 0, 0);
|
||||
Datetime end (year, month, 1, 0, 0, 0);
|
||||
_range = Range (start, end);
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ Range Exclusion::rangeFromTimeBlock (
|
|||
{
|
||||
int hh, mm, ss;
|
||||
if (pig.getHMS (hh, mm, ss))
|
||||
return Range (start, Datetime (start.month (), start.day (), start.year (), hh, mm, ss));
|
||||
return Range (start, Datetime (start.year (), start.month (), start.day (), hh, mm, ss));
|
||||
|
||||
throw format ("Malformed time block '{1}'.", block);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ Range Exclusion::rangeFromTimeBlock (
|
|||
{
|
||||
int hh, mm, ss;
|
||||
if (pig.getHMS (hh, mm, ss))
|
||||
return Range (Datetime (start.month (), start.day (), start.year (), hh, mm, ss), end);
|
||||
return Range (Datetime (start.year (), start.month (), start.day (), hh, mm, ss), end);
|
||||
|
||||
throw format ("Malformed time block '{1}'.", block);
|
||||
}
|
||||
|
@ -182,8 +182,8 @@ Range Exclusion::rangeFromTimeBlock (
|
|||
pig.skip ('-') &&
|
||||
pig.getHMS (hh2, mm2, ss2))
|
||||
return Range (
|
||||
Datetime (start.month (), start.day (), start.year (), hh1, mm1, ss1),
|
||||
Datetime (start.month (), start.day (), start.year (), hh2, mm2, ss2));
|
||||
Datetime (start.year (), start.month (), start.day (), hh1, mm1, ss1),
|
||||
Datetime (start.year (), start.month (), start.day (), hh2, mm2, ss2));
|
||||
|
||||
throw format ("Malformed time block '{1}'.", block);
|
||||
}
|
||||
|
|
|
@ -60,18 +60,18 @@ int main (int, char**)
|
|||
// H [...
|
||||
// I [...
|
||||
Range refClosed;
|
||||
refClosed.start = Datetime (6, 1, 2016);
|
||||
refClosed.end = Datetime (6, 30, 2016);
|
||||
refClosed.start = Datetime (2016, 6, 1);
|
||||
refClosed.end = Datetime (2016, 6, 30);
|
||||
|
||||
Range testA; testA.start = Datetime (4, 1, 2016); testA.end = Datetime (4, 30, 2016);
|
||||
Range testB; testB.start = Datetime (5, 15, 2016); testB.end = Datetime (6, 15, 2016);
|
||||
Range testC; testC.start = Datetime (6, 10, 2016); testC.end = Datetime (6, 20, 2016);
|
||||
Range testD; testD.start = Datetime (6, 15, 2016); testD.end = Datetime (7, 15, 2016);
|
||||
Range testE; testE.start = Datetime (8, 1, 2016); testE.end = Datetime (8, 31, 2016);
|
||||
Range testF; testF.start = Datetime (5, 15, 2016); testF.end = Datetime (7, 15, 2016);
|
||||
Range testG; testG.start = Datetime (5, 15, 2016);
|
||||
Range testH; testH.start = Datetime (6, 15, 2016);
|
||||
Range testI; testI.start = Datetime (7, 15, 2016);
|
||||
Range testA; testA.start = Datetime (2016, 4, 1); testA.end = Datetime (2016, 4, 30);
|
||||
Range testB; testB.start = Datetime (2016, 5, 15); testB.end = Datetime (2016, 6, 15);
|
||||
Range testC; testC.start = Datetime (2016, 6, 10); testC.end = Datetime (2016, 6, 20);
|
||||
Range testD; testD.start = Datetime (2016, 6, 15); testD.end = Datetime (2016, 7, 15);
|
||||
Range testE; testE.start = Datetime (2016, 8, 1); testE.end = Datetime (2016, 8, 31);
|
||||
Range testF; testF.start = Datetime (2016, 5, 15); testF.end = Datetime (2016, 7, 15);
|
||||
Range testG; testG.start = Datetime (2016, 5, 15);
|
||||
Range testH; testH.start = Datetime (2016, 6, 15);
|
||||
Range testI; testI.start = Datetime (2016, 7, 15);
|
||||
|
||||
t.notok (refClosed.overlap (testA), "Range: ! refClosed.overlap(testA)");
|
||||
t.ok (refClosed.overlap (testB), "Range: refClosed.overlap(testB)");
|
||||
|
@ -94,7 +94,7 @@ int main (int, char**)
|
|||
// H [...
|
||||
// I [...
|
||||
Range refOpen;
|
||||
refOpen.start = Datetime (6, 1, 2016);
|
||||
refOpen.start = Datetime (2016, 6, 1);
|
||||
|
||||
t.notok (refOpen.overlap (testA), "Range: ! refOpen.overlap(testA)");
|
||||
t.ok (refOpen.overlap (testB), "Range: refOpen.overlap(testB)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue