API Documentation
Bases: when_exactly.custom_interval.CustomInterval
The Year
represents an entire year, starting from January 1 to December 31.
Creating a Year
>>> import when_exactly as we
>>> year = we.Year(2025)
>>> year
Year(2025)
>>> str(year)
'2025'
The Months of a Year
Get the Months
of a year.
>>> months = year.months
>>> len(months)
12
>>> months[0]
Month(2025, 1)
>>> months[-2:]
Months([Month(2025, 11), Month(2025, 12)])
The Weeks of a Year
Get the Weeks
of a year.
>>> weeks = year.weeks
>>> len(weeks)
52
>>> weeks[0]
Week(2025, 1)
Source code in src\when_exactly\api.py
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
__init__(year)
Create a Year.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
year
|
int
|
The year to represent. |
required |
Examples:
>>> import when_exactly as we
>>> year = we.Year(2025)
>>> year
Year(2025)
>>> str(year)
'2025'
Source code in src\when_exactly\api.py
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 |
|
month(month)
Get a specific month of the year. Args: month (int): The month number (1-12).
Source code in src\when_exactly\api.py
126 127 128 129 130 131 132 133 134 |
|