Period
Represents a period with a start and end date.
Attributes:
| Name | Type | Description |
|---|---|---|
start |
datetime
|
The start date of the period. |
end |
datetime
|
The end date of the period. |
Source code in hazbin_hotel/src/period.py
6 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
end: datetime
property
start: datetime
property
__init__(start, end)
Initializes a Period object with a start and end date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
datetime
|
The start date of the period. |
required |
end
|
datetime
|
The end date of the period. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the start date is after the end date. |
Source code in hazbin_hotel/src/period.py
change_end(end)
Changes the end date of the period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
end
|
datetime
|
The new end date. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the end date was successfully changed, False otherwise. |
Examples:
>>> from datetime import datetime
>>> period = Period(datetime(2023, 1, 2), datetime(2023, 1, 3))
>>> period.change_end(datetime(2023, 1, 1))
False
>>> period.change_end(datetime(2023, 1, 4))
True
>>> print(period.end)
2023-01-04 00:00:00
Source code in hazbin_hotel/src/period.py
change_start(start)
Changes the start date of the period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
datetime
|
The new start date. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the start date was successfully changed, False otherwise. |
Examples:
>>> from datetime import datetime
>>> period = Period(datetime(2023, 1, 1), datetime(2023, 1, 2))
>>> period.change_start(datetime(2023, 1, 3))
False
>>> period.change_start(datetime(2023, 1, 2))
True
>>> print(period.start)
2023-01-02 00:00:00