| commit 196: | 20944f811650 |
| parent 194: | 31a02f854246 |
| branch: | default |
Fixed incorrect output for doctest blocks
Changed (Δ111 bytes):
raw changeset »
NEWS (7 lines added, 0 lines removed)
doc/source/usage.rst (20 lines added, 16 lines removed)
1 |
xxxx-xx-xx: 0.3.1 |
|
2 |
================= |
|
3 |
||
4 |
Bugfixes: |
|
5 |
||
6 |
* Fixed incorrect output for doctest blocks |
|
7 |
||
1 |
8 |
2010-03-09: 0.3.0 |
2 |
9 |
================= |
3 |
10 |
Up to file-list doc/source/usage.rst:
| … | … | @@ -34,7 +34,7 @@ pass the proper parser to :class:`chrono |
34 |
34 |
Date parsing is done simply by instantiating a :class:`chrono.Date` object, |
35 |
35 |
passing the date string to be parsed as input. Once instantiated, the |
36 |
36 |
attributes :attr:`chrono.Date.year`, :attr:`chrono.Date.month`, and |
37 |
:attr:`chrono.Date.day` will contain the respective date parts: |
|
37 |
:attr:`chrono.Date.day` will contain the respective date parts: |
|
38 |
38 |
|
39 |
39 |
.. doctest:: |
40 |
40 |
|
| … | … | @@ -46,7 +46,7 @@ attributes :attr:`chrono.Date.year`, :at |
46 |
46 |
>>> date.day |
47 |
47 |
23 |
48 |
48 |
|
49 |
To retrieve all the attributes at once, use :meth:`chrono.Date.get`: |
|
49 |
To retrieve all the attributes at once, use :meth:`chrono.Date.get`: |
|
50 |
50 |
|
51 |
51 |
.. doctest:: |
52 |
52 |
|
| … | … | @@ -55,7 +55,7 @@ To retrieve all the attributes at once, |
55 |
55 |
(2009, 7, 23) |
56 |
56 |
|
57 |
57 |
The default :class:`chrono.parser.CommonParser` parser handles most normal |
58 |
date formats, such as: |
|
58 |
date formats, such as: |
|
59 |
59 |
|
60 |
60 |
.. doctest:: |
61 |
61 |
|
| … | … | @@ -84,7 +84,7 @@ date formats, such as:: |
84 |
84 |
(2009, 7, 1) |
85 |
85 |
|
86 |
86 |
In order to parse all valid date formats for a region, you can pass the |
87 |
proper parser class to :class:`chrono.Date`: |
|
87 |
proper parser class to :class:`chrono.Date`: |
|
88 |
88 |
|
89 |
89 |
.. doctest:: |
90 |
90 |
|
| … | … | @@ -99,7 +99,7 @@ proper parser class to :class:`chrono.Da |
99 |
99 |
If :class:`chrono.Date` is passed an invalid date it will raise either |
100 |
100 |
:exc:`chrono.error.ParseError` for invalid/unknown format, or a subclass |
101 |
101 |
of :exc:`chrono.error.DateError` (such as :exc:`chrono.error.MonthError`) |
102 |
if the date was parsed properly but contained an invalid date value: |
|
102 |
if the date was parsed properly but contained an invalid date value: |
|
103 |
103 |
|
104 |
104 |
.. doctest:: |
105 |
105 |
|
| … | … | @@ -112,7 +112,7 @@ if the date was parsed properly but cont |
112 |
112 |
MonthError: Month '13' not in range 1-12 |
113 |
113 |
|
114 |
114 |
You can also pass a range of non-string inputs to the class, which will |
115 |
be handled according to the object type: |
|
115 |
be handled according to the object type: |
|
116 |
116 |
|
117 |
117 |
.. doctest:: |
118 |
118 |
|
| … | … | @@ -136,7 +136,7 @@ For a complete list of all accepted inpu |
136 |
136 |
documentation. |
137 |
137 |
|
138 |
138 |
To parse date strings without instantiating a :class:`chrono.Date` object, you |
139 |
can use the parser classes directly: |
|
139 |
can use the parser classes directly: |
|
140 |
140 |
|
141 |
141 |
.. doctest:: |
142 |
142 |
|
| … | … | @@ -178,7 +178,7 @@ the proper calendar to :class:`chrono.Da |
178 |
178 |
affects functionality related to week numbers or week days. |
179 |
179 |
|
180 |
180 |
:class:`chrono.Date` has a number of methods for retreiving calendar-related |
181 |
information about about a date, such as: |
|
181 |
information about about a date, such as: |
|
182 |
182 |
|
183 |
183 |
.. doctest:: |
184 |
184 |
|
| … | … | @@ -199,7 +199,7 @@ information about about a date, such as: |
199 |
199 |
4 |
200 |
200 |
|
201 |
201 |
To use the US calendar instead, pass the :class:`chrono.calendar.USCalendar` |
202 |
class to :class:`chrono.Date`: |
|
202 |
class to :class:`chrono.Date`: |
|
203 |
203 |
|
204 |
204 |
.. doctest:: |
205 |
205 |
|
| … | … | @@ -216,7 +216,7 @@ documentation. |
216 |
216 |
|
217 |
217 |
If you would like to retreive calendar information without having to |
218 |
218 |
instantiate a :class:`chrono.Date` object, you can use the underlying |
219 |
calendar class directly: |
|
219 |
calendar class directly: |
|
220 |
220 |
|
221 |
221 |
.. doctest:: |
222 |
222 |
|
| … | … | @@ -241,7 +241,7 @@ attributes. If any of these are set to a |
241 |
241 |
the object will automatically update the attributes to a proper date, by |
242 |
242 |
incrementing or decrementing values as necessary. |
243 |
243 |
|
244 |
Here are some examples: |
|
244 |
Here are some examples: |
|
245 |
245 |
|
246 |
246 |
.. doctest:: |
247 |
247 |
|
| … | … | @@ -266,7 +266,9 @@ Here are some examples:: |
266 |
266 |
When the date is on one of the last days of a month, and the :attr:`chrono.Date.month` or |
267 |
267 |
:attr:`chrono.Date.year` attribute is changed, you may get a result which is in a different |
268 |
268 |
month than the one you expect. This happens when the day number is out of range |
269 |
for the new month, due to differences in month lengths: |
|
269 |
for the new month, due to differences in month lengths: |
|
270 |
||
271 |
.. doctest:: |
|
270 |
272 |
|
271 |
273 |
>>> date = chrono.Date("2009-07-31") |
272 |
274 |
>>> date.month -= 1 |
| … | … | @@ -275,7 +277,9 @@ Here are some examples:: |
275 |
277 |
|
276 |
278 |
When :attr:`chrono.Date.month` is set to 6, the date will become 2009-06-31. Since June |
277 |
279 |
only has 30 days this will trigger the overflow-handling that the date arithmetic relies |
278 |
on, and update the date to a valid date. The same happens with leap years: |
|
280 |
on, and update the date to a valid date. The same happens with leap years: |
|
281 |
||
282 |
.. doctest:: |
|
279 |
283 |
|
280 |
284 |
>>> date = chrono.Date("2008-02-29") |
281 |
285 |
>>> date.year += 1 |
| … | … | @@ -287,7 +291,7 @@ Formatting |
287 |
291 |
|
288 |
292 |
Date formatting is done via the :meth:`chrono.Date.format` method, which |
289 |
293 |
takes a string containing substitution variables of the form ``$name`` or |
290 |
``${name}``, and replaces them with actual values: |
|
294 |
``${name}``, and replaces them with actual values: |
|
291 |
295 |
|
292 |
296 |
.. doctest:: |
293 |
297 |
|
| … | … | @@ -306,7 +310,7 @@ Comparison |
306 |
310 |
---------- |
307 |
311 |
|
308 |
312 |
Date comparisons can be done using the normal Python comparison operators: ``==``, |
309 |
``!=``, ``>``, and ``<``: |
|
313 |
``!=``, ``>``, and ``<``: |
|
310 |
314 |
|
311 |
315 |
.. doctest:: |
312 |
316 |
|
| … | … | @@ -322,7 +326,7 @@ Date comparisons can be done using the n |
322 |
326 |
If the value that is being compared with is not a :class:`chrono.Date` object, it will |
323 |
327 |
be converted to one if possible. This allows for comparisons with strings, UNIX timestamps, |
324 |
328 |
:class:`time.struct_time` or :class:`datetime.date` objects, and any other value that |
325 |
:class:`chrono.Date` is able to process: |
|
329 |
:class:`chrono.Date` is able to process: |
|
326 |
330 |
|
327 |
331 |
.. doctest:: |
328 |
332 |
