Skip to content

Commit e969811

Browse files
committed
README code blocks
1 parent 4e097a0 commit e969811

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ we can also convert such collection to a list.
109109

110110
The `Day`, `Week`, `Month, etc. classes have `.get_index_for_date(…)` and `.get_date_from_index(…)` methods, which allow to determine how many days, weeks, months, quarters and years are between `date.min` and the date given, and convert this back to a date. For example:
111111

112-
```
112+
```python3
113113
Week.get_index_for_date(date(1958, 3, 25)) # 102123
114114
Week.get_date_from_index(102123) # date(1958, 3, 24)
115115
```
@@ -118,19 +118,19 @@ so 1958-03-25 is the 102'123 week since 0001-01-01, and that week starts the 24<
118118

119119
We can also use the index to get a `TimUnit` with:
120120

121-
```
121+
```python3
122122
Week[102123] # Week(date(1958, 3, 24))
123123
```
124124

125125
moreover a week itself can be subscripted, for example:
126126

127-
```
127+
```python3
128128
Week(date(1958, 3, 24))[2] # date(1958, 3, 26)
129129
```
130130

131131
one can also slice to created an object that is a sliced "view" that generates `Week`s or `date`s in the week respectively. This view can then be sliced or indexed further. For example:
132132

133-
```
133+
```python3
134134
Week[102123:105341:2]
135135
```
136136

@@ -139,7 +139,7 @@ is a collection of `Week` objects between `1958-03-24` and `2019-11-25` each tim
139139

140140
The `Week` class itself is also iterable, for example:
141141

142-
```
142+
```python3
143143
for week in Week:
144144
print(week)
145145
```
@@ -148,9 +148,9 @@ will start enumerating over all weeks since 0001-01-01.
148148

149149
A time unit also has a length: the number of time units that can be represented, so:
150150

151-
```
151+
```python3
152152
len(Week) # 521722
153-
``
153+
```
154154

155155
means the software can represent 521'722 weeks from 0001-01-01 to 9999-12-26.
156156

0 commit comments

Comments
 (0)