This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients amaury.forgeotdarc, belopolsky, jribbens, mark.dickinson, vstinner, webograph
Date 2008-11-15.12:36:08
SpamBayes Score 0.0007972063
Marked as misclassified No
Message-id <200811151335.04167.victor.stinner@haypocalc.com>
In-reply-to <1226744760.36.0.834431885725.issue2706@psf.upfronthosting.co.za>
Content
Some examples to help the choice (using the last patch).

int
---

2L
>>> print dt2 * 2
3:08:38
>>> print dt1 - dt2 * 2
0:51:22
>>> divmod(dt1, dt2)
(2L, datetime.timedelta(0, 3082))
>>> print timedelta(0, 3082)
0:51:22

In 4 hours, you can watch the movie twice, and then your have 51 minutes left.

Operations used:
 - timedelta // timedelta
 - timedelta * int
 - divmod(timedelta, timedelta)

float
-----

0.21258172822053367
>>> "Progress: %.1f%%" % ((dt1 / dt2) * 100.0)
'Progress: 21.3%'
>>> dt2 * 0.75
...
TypeError: unsupported operand type(s) for *: 'datetime.timedelta' and 'float'
>>> print (dt2 * 3) // 4
1:10:44.250000

If you are seen this movie since 20 minutes, you're at 21% of the total. If 
you want to jump to 75%, it will be at 1:10:44.

Note: timedelta * float is not implemented yet.

Operations used:
 - timedelta / timedelta
 - timedelta * int and timedelta // int (because timdelta / float is 
   not implemented yet)
History
Date User Action Args
2008-11-15 12:36:13vstinnersetrecipients: + vstinner, jribbens, amaury.forgeotdarc, mark.dickinson, belopolsky, webograph
2008-11-15 12:36:12vstinnerlinkissue2706 messages
2008-11-15 12:36:12vstinnercreate