[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 39f6c8c 2/2: Refactor, adding an argument to
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 39f6c8c 2/2: Refactor, adding an argument to years_and_months_since() |
Date: |
Thu, 22 Jun 2017 07:14:02 -0400 (EDT) |
branch: master
commit 39f6c8c50f42e74105bf28aa4e2d50994e2bf41b
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Refactor, adding an argument to years_and_months_since()
The new argument is specified as 'true' in all cases and ignored for
now. Soon, it will affect behavior and be specified differently in
certain cases.
---
calendar_date.cpp | 2 ++
calendar_date.hpp | 1 +
calendar_date_test.cpp | 28 ++++++++++++++--------------
financial.cpp | 2 +-
gpt_input.cpp | 2 ++
ihs_acctval.cpp | 4 ++--
input_harmonization.cpp | 2 ++
input_xml_io.cpp | 1 +
mec_input.cpp | 2 ++
9 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/calendar_date.cpp b/calendar_date.cpp
index 91a1450..2ecd58d 100644
--- a/calendar_date.cpp
+++ b/calendar_date.cpp
@@ -519,8 +519,10 @@ int attained_age
std::pair<int,int> years_and_months_since
(calendar_date const& base_date
,calendar_date const& other_date
+ ,bool is_curtate
)
{
+(void)&is_curtate;
if(other_date < base_date)
{
alarum()
diff --git a/calendar_date.hpp b/calendar_date.hpp
index ec65d1a..374def4 100644
--- a/calendar_date.hpp
+++ b/calendar_date.hpp
@@ -208,6 +208,7 @@ int attained_age
std::pair<int,int> years_and_months_since
(calendar_date const& base_date
,calendar_date const& other_date
+ ,bool is_curtate
);
int duration_floor
diff --git a/calendar_date_test.cpp b/calendar_date_test.cpp
index 02d5dd6..ee2783c 100644
--- a/calendar_date_test.cpp
+++ b/calendar_date_test.cpp
@@ -625,7 +625,7 @@ void CalendarDateTest::TestIntegralDuration()
BOOST_TEST_EQUAL(-1, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL(-1, duration_ceiling(base_date, other_date));
BOOST_TEST_THROW
- (years_and_months_since(base_date, other_date)
+ (years_and_months_since(base_date, other_date, true)
,std::runtime_error
,"Second date (1999-01-01) precedes first date (2000-01-01)."
);
@@ -633,14 +633,14 @@ void CalendarDateTest::TestIntegralDuration()
other_date = calendar_date(2000, 1, 1);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 0, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
other_date = calendar_date(2001, 1, 1);
BOOST_TEST_EQUAL( 1, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 1, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
@@ -653,14 +653,14 @@ void CalendarDateTest::TestIntegralDuration()
other_date = calendar_date(2000, 2, 2);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 1, ym.second);
other_date = calendar_date(2001, 2, 2);
BOOST_TEST_EQUAL( 1, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 2, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 1, ym.first );
BOOST_TEST_EQUAL( 1, ym.second);
@@ -683,28 +683,28 @@ void CalendarDateTest::TestIntegralDuration()
other_date = calendar_date(2000, 2, 29);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 0, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
other_date = calendar_date(2000, 3, 1);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
other_date = calendar_date(2001, 2, 28);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 1, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
other_date = calendar_date(2001, 3, 1);
BOOST_TEST_EQUAL( 1, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 1, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
@@ -715,28 +715,28 @@ void CalendarDateTest::TestIntegralDuration()
base_date = calendar_date(1999, 2, 28);
BOOST_TEST_EQUAL( 1, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 2, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 1, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
base_date = calendar_date(1999, 3, 1);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL(11, ym.second);
base_date = calendar_date(2000, 2, 28);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 1, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
base_date = calendar_date(2000, 2, 29);
BOOST_TEST_EQUAL( 0, duration_floor (base_date, other_date));
BOOST_TEST_EQUAL( 0, duration_ceiling(base_date, other_date));
- ym = years_and_months_since(base_date, other_date);
+ ym = years_and_months_since(base_date, other_date, true);
BOOST_TEST_EQUAL( 0, ym.first );
BOOST_TEST_EQUAL( 0, ym.second);
@@ -797,7 +797,7 @@ void
CalendarDateTest::TestYearAndMonthDifferenceExhaustively()
;++e
)
{
- std::pair<int,int> ym = years_and_months_since(d, e);
+ std::pair<int,int> ym = years_and_months_since(d, e, true);
int y = ym.first;
int m = ym.second;
calendar_date a = add_years_and_months(d, y, m, true);
diff --git a/financial.cpp b/financial.cpp
index 13f003b..3cf7cef 100644
--- a/financial.cpp
+++ b/financial.cpp
@@ -73,7 +73,7 @@ double list_bill_premium
if(bill_date < cert_date) return 0.0;
// Number of alpha months in the twelvemonth starting on bill date.
int const inforce_months_mod_12 = years_and_months_since
- (cert_date, bill_date).second
+ (cert_date, bill_date, true).second
;
// Number of delta months in the twelvemonth starting on bill date.
int const months_ante = 12 - inforce_months_mod_12;
diff --git a/gpt_input.cpp b/gpt_input.cpp
index 7023b2e..c2b5972 100644
--- a/gpt_input.cpp
+++ b/gpt_input.cpp
@@ -535,6 +535,7 @@ void gpt_input::DoTransmogrify()
std::pair<int,int> ym0 = years_and_months_since
(EffectiveDate .value()
,InforceAsOfDate.value()
+ ,true
);
InforceYear = ym0.first;
InforceMonth = ym0.second;
@@ -542,6 +543,7 @@ void gpt_input::DoTransmogrify()
std::pair<int,int> ym1 = years_and_months_since
(LastMaterialChangeDate.value()
,InforceAsOfDate .value()
+ ,true
);
InforceContractYear = ym1.first;
InforceContractMonth = ym1.second;
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 28ee376..f46cbf5 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -1144,7 +1144,7 @@ void AccountValue::set_list_bill_year_and_month()
auto const& bill_date = yare_input_.ListBillDate;
if(bill_date < cert_date) return;
- auto z = years_and_months_since(cert_date, bill_date);
+ auto z = years_and_months_since(cert_date, bill_date, true);
auto const a = add_years_and_months(cert_date, z.first, z.second, true);
if(a < bill_date)
{
@@ -1159,7 +1159,7 @@ void AccountValue::set_list_bill_year_and_month()
// Temporary supplemental code for acceptance testing.
int const inforce_months_mod_12 = years_and_months_since
- (cert_date, bill_date).second
+ (cert_date, bill_date, true).second
;
// Number of delta months in the twelvemonth starting on bill date.
int const months_ante = 12 - inforce_months_mod_12;
diff --git a/input_harmonization.cpp b/input_harmonization.cpp
index 1b834ca..e812cd2 100644
--- a/input_harmonization.cpp
+++ b/input_harmonization.cpp
@@ -1116,6 +1116,7 @@ void Input::set_inforce_durations_from_dates()
std::pair<int,int> ym0 = years_and_months_since
(EffectiveDate .value()
,InforceAsOfDate.value()
+ ,true
);
InforceYear = ym0.first;
InforceMonth = ym0.second;
@@ -1123,6 +1124,7 @@ void Input::set_inforce_durations_from_dates()
std::pair<int,int> ym1 = years_and_months_since
(LastMaterialChangeDate.value()
,InforceAsOfDate .value()
+ ,true
);
InforceContractYear = ym1.first;
InforceContractMonth = ym1.second;
diff --git a/input_xml_io.cpp b/input_xml_io.cpp
index 193c4b1..8066214 100644
--- a/input_xml_io.cpp
+++ b/input_xml_io.cpp
@@ -581,6 +581,7 @@ void Input::redintegrate_ex_post
std::pair<int,int> ym0 = years_and_months_since
(EffectiveDate .value()
,InforceAsOfDate.value()
+ ,true
);
InforceYear = ym0.first;
InforceMonth = ym0.second;
diff --git a/mec_input.cpp b/mec_input.cpp
index 004b8d4..8ccee30 100644
--- a/mec_input.cpp
+++ b/mec_input.cpp
@@ -482,6 +482,7 @@ void mec_input::DoTransmogrify()
std::pair<int,int> ym0 = years_and_months_since
(EffectiveDate .value()
,InforceAsOfDate.value()
+ ,true
);
InforceYear = ym0.first;
InforceMonth = ym0.second;
@@ -489,6 +490,7 @@ void mec_input::DoTransmogrify()
std::pair<int,int> ym1 = years_and_months_since
(LastMaterialChangeDate.value()
,InforceAsOfDate .value()
+ ,true
);
InforceContractYear = ym1.first;
InforceContractMonth = ym1.second;