Align time_of_day with hh_mm_ss

Per committee review
This commit is contained in:
Howard Hinnant
2019-03-19 19:50:30 -04:00
parent f782ae98f0
commit b5d025ea2f
8 changed files with 99 additions and 200 deletions

View File

@@ -85,16 +85,10 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:00:00");
t2.make12();
auto h = make12(t2.hours());
os.str("");
assert(t2.hours() == hours{1});
assert(h == hours{1});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "1:00:00PM");
t2.make24();
os.str("");
assert(t2.hours() == hours{13});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "13:00:00");
assert(!is_am(t2.hours()));
assert(is_pm(t2.hours()));
}

View File

@@ -108,12 +108,4 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:07:06.0480");
t2.make12();
os.str("");
os << t2;
assert(os.str() == "1:07:06.0480PM");
t2.make24();
os.str("");
os << t2;
assert(os.str() == "13:07:06.0480");
}

View File

@@ -101,22 +101,4 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:07:05.022");
t2.make12();
os.str("");
assert(t2.hours() == hours{1});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.subseconds() == milliseconds{22});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "1:07:05.022PM");
t2.make24();
os.str("");
assert(t2.hours() == hours{13});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.subseconds() == milliseconds{22});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "13:07:05.022");
}

View File

@@ -89,18 +89,4 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:07:00");
t2.make12();
os.str("");
assert(t2.hours() == hours{1});
assert(t2.minutes() == minutes{7});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "1:07:00PM");
t2.make24();
os.str("");
assert(t2.hours() == hours{13});
assert(t2.minutes() == minutes{7});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "13:07:00");
}

View File

@@ -101,22 +101,4 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:07:05.000000022");
t2.make12();
os.str("");
assert(t2.hours() == hours{1});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.subseconds() == nanoseconds{22});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "1:07:05.000000022PM");
t2.make24();
os.str("");
assert(t2.hours() == hours{13});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.subseconds() == nanoseconds{22});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "13:07:05.000000022");
}

View File

@@ -93,20 +93,4 @@ main()
ostringstream os;
os << t2;
assert(os.str() == "13:07:05");
t2.make12();
os.str("");
assert(t2.hours() == hours{1});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "1:07:05PM");
t2.make24();
os.str("");
assert(t2.hours() == hours{13});
assert(t2.minutes() == minutes{7});
assert(t2.seconds() == seconds{5});
assert(t2.to_duration() == t1.to_duration());
os << t2;
assert(os.str() == "13:07:05");
}