Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5f5f87

Browse files
committed
Complete the markup for timedelta objects.
Fix a curly brace that should have been a paren.
1 parent ae3bbf5 commit c5f5f87

1 file changed

Lines changed: 28 additions & 36 deletions

File tree

Doc/lib/libdatetime.tex

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,25 @@ \subsection{\class{timedelta} Objects \label{datetime-timedelta}}
219219
{(1)}
220220
\lineiii{\var{t1} = \var{t2} * \var{i} or \var{t1} = \var{i} * \var{t2}}
221221
{Delta multiplied by an integer or long.
222-
Afterwards \var{t1} // i == \var{t2} is true, provided i != 0.
222+
Afterwards \var{t1} // i == \var{t2} is true, provided \code{i != 0}.
223223
In general, \var{t1} * i == \var{t1} * (i-1) + \var{t1} is true.}
224224
{(1)}
225225
\lineiii{\var{t1} = \var{t2} // \var{i}}
226226
{The floor is computed and the remainder (if any) is thrown away.}
227227
{(2)}
228+
\lineiii{+\var{t1}}
229+
{Returns a \class{timedelta} object with the same value.}
230+
{}
231+
\lineiii{-\var{t1}}
232+
{equivalent to \class{timedelta}(-\var{t1.days}, -\var{t1.seconds},
233+
-\var{t1.microseconds}),and to \var{t1}* -1.}
234+
{(1)(3)}
235+
\lineiii{abs(\var{t})}
236+
{equivalent to +\var{t} when \code{t.days >= 0}, and to -\var{t} when
237+
\code{t.days < 0}.}
238+
{(1)}
239+
240+
228241
\end{tableiii}
229242
\noindent
230243
Notes:
@@ -235,45 +248,24 @@ \subsection{\class{timedelta} Objects \label{datetime-timedelta}}
235248

236249
\item[(2)]
237250
Division by 0 raises \exception{ZeroDivisionError}.
238-
\end{description}
239-
240-
241-
242-
243-
\begin{itemize}
244-
\item
245-
certain additions and subtractions with date, datetime, and datimetz
246-
objects (see below)
247-
248-
\item
249-
+timedelta -> timedelta
250-
Returns a \class{timedelta} object with the same value.
251251

252-
\item
253-
-timedelta -> timedelta
254-
-t is equivalent to timedelta(-t.days, -t.seconds, -t.microseconds),
255-
and to t*-1. This is exact, but may overflow (for example,
256-
-timedelta.max is not representable as a \class{timedelta} object).
252+
\item[(3)]
253+
-\var{timedelta.max} is not representable as a \class{timedelta} object).
257254

258-
\item
259-
\code{abs(timedelta) -> timedelta}:
260-
\code{abs(t)} is equivalent to +t when \code{t.days >= 0}, and to -t when
261-
\code{t.days < 0}. This is exact, and cannot overflow.
255+
\end{description}
262256

263-
\item
264-
comparison of \class{timedelta} to timedelta; the \class{timedelta} representing
265-
the smaller duration is considered to be the smaller timedelta
257+
In addition to the operations listed above \class{timedelta} objects
258+
support certain additions and subtractions with \class{date},
259+
\class{datetime}, and \class{datimetz} objects (see below).
266260

267-
\item
268-
hash, use as dict key
261+
Comparisons of \class{timedelta} objects are supported with the
262+
\class{timedelta} object representing the smaller duration considered
263+
to be the smaller timedelta.
269264

270-
\item
271-
efficient pickling
272-
273-
\item
274-
in Boolean contexts, a \class{timedelta} object is considered to be true
275-
if and only if it isn't equal to \code{timedelta(0)}
276-
\end{itemize}
265+
\class{timedelta} objects are hashable (usable as dictionary key),
266+
support efficient pickling, and in Boolean contexts, a \class{timedelta}
267+
object is considered to be true if and only if it isn't equal to
268+
\code{timedelta(0)}.
277269

278270

279271
\subsection{\class{date} Objects \label{datetime-date}}
@@ -922,7 +914,7 @@ \subsection{\class{tzinfo} Objects \label{datetime-tzinfo}}
922914
best response. For example, returning \code{None} is appropriate if the
923915
class wishes to say that timetz objects don't participate in the
924916
\class{tzinfo} protocol. In other applications, it may be more useful
925-
for \code{utcoffset(None}} to return the standard UTC offset.
917+
for \code{utcoffset(None)} to return the standard UTC offset.
926918

927919
When a \class{datetimetz} object is passed in response to a
928920
\class{datetimetz} method, \code{dt.tzinfo} is the same object as

0 commit comments

Comments
 (0)