diff --git a/eeco/costs.py b/eeco/costs.py index c575bb8..ef483fa 100644 --- a/eeco/costs.py +++ b/eeco/costs.py @@ -1061,7 +1061,7 @@ def get_converted_consumption_data( def get_charge_array_duration(key): - """Parse a charge array key to determine the duration of the charge period. + """Parse a charge array key to determine the duration of the charge period in days. Parameters ---------- @@ -1093,7 +1093,7 @@ def get_charge_array_duration(key): try: start_date = dt.datetime.strptime(start_date_str, date_format) end_date = dt.datetime.strptime(end_date_str, date_format) - return (end_date - start_date).days + return (end_date - start_date).days + 1 except ValueError: continue diff --git a/eeco/tests/test_costs.py b/eeco/tests/test_costs.py index af37d80..bb15259 100644 --- a/eeco/tests/test_costs.py +++ b/eeco/tests/test_costs.py @@ -2105,11 +2105,11 @@ def test_calculate_export_revenue( "key, expected", [ # YYYYMMDD format - ("electric_demand_peak_20240710_20240710_100", 0), - ("electric_demand_peak_20240710_20240731_100", 21), + ("electric_demand_peak_20240710_20240710_100", 1), + ("electric_demand_peak_20240710_20240731_100", 22), # YYYY-MM-DD format - ("electric_energy_0_2024-07-10_2024-07-10_0", 0), - ("electric_energy_0_2024-07-10_2024-07-31_0", 21), + ("electric_energy_0_2024-07-10_2024-07-10_0", 1), + ("electric_energy_0_2024-07-10_2024-07-31_0", 22), ], ) def test_get_charge_array_duration(key, expected):