Validity Period
This part of the project documentation focuses on
an information-oriented approach. Use it as a
reference for the technical implementation of the
pact_methodology
project code.
ValidityPeriod
Represents a validity period with a start and end date.
Attributes:
Name | Type | Description |
---|---|---|
start |
DateTime
|
The start date of the validity period. |
end |
DateTime
|
The end date of the validity period. |
Source code in pact_methodology/product_footprint/validity_period.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
__init__(*, start=None, end=None, reference_period_end=None)
Represents a validity period with a start and end date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
DateTime
|
The start date of the validity period. Defaults to None. |
None
|
end
|
DateTime
|
The end date of the validity period. Defaults to None. |
None
|
reference_period_end
|
DateTime
|
The reference date to calculate default start and end if not provided. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If start or end dates are not provided and reference period end date is not provided. |
ValueError
|
If start or end dates are not DateTime objects. |
ValueError
|
If start date is not before end date. |
Source code in pact_methodology/product_footprint/validity_period.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
is_valid(reference_period_end)
Checks if the validity period is valid with respect to the reference period end date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_period_end
|
DateTime
|
The reference period end date. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the validity period is valid, False otherwise. |
Raises:
Type | Description |
---|---|
ValueError
|
If reference period end date is not a DateTime object. |
Source code in pact_methodology/product_footprint/validity_period.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
three_years_from_end(end_date)
classmethod
Calculate the date that is 3 years from the given end date.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
end_date
|
DateTime
|
The end date to calculate from. |
required |
Returns:
Name | Type | Description |
---|---|---|
DateTime |
DateTime
|
The date that is 3 years from the given end date. |
Source code in pact_methodology/product_footprint/validity_period.py
55 56 57 58 59 60 61 62 63 64 65 66 67 |
|