Relative dates

- eoq and soq to refer to the end and start of the quarter
  (thanks to David French)
This commit is contained in:
Federico Hernandez
2011-08-04 01:40:31 +02:00
parent e5ae145df2
commit 6e1ba161b1
5 changed files with 59 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ Context context;
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (168);
UnitTest t (174);
try
{
@@ -346,6 +346,16 @@ int main (int argc, char** argv)
t.is (later.day (), 18, "later -> d = 18");
t.is (later.year (), 2038, "later -> y = 2038");
// Quarters
Date soq ("soq");
Date eoq ("eoq");
t.is (soq.day (), 1, "soq is the first day of a month");
t.is (eoq.day () / 10, 3, "eoq is the 30th or 31th of a month");
t.is (soq.month () % 3, 1, "soq month is 1, 4, 7 or 10");
t.is (eoq.month () % 3, 0, "eoq month is 3, 6, 9 or 12");
t.ok (soq.sameYear (now), "soq is in same year as now");
t.ok (eoq.sameYear (now), "eoq is in same year as now");
// Date::sameHour
Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S");
Date r18 ("6/7/2010 01:59:59", "m/d/Y H:N:S");