[IronPython] System.TimeSpan can't add time from IronPython

Dino Viehland dinov at microsoft.com
Fri Nov 6 20:13:40 CET 2009


span.Add() returns a new TimeSpan object, it does not mutate the existing object.  You can see that the result of span.Add(hour) printed out the 2:00:00 time span in the repl that was returned.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jan Rouvillain
Sent: Friday, November 06, 2009 11:08 AM
To: Discussion of IronPython
Subject: [IronPython] System.TimeSpan can't add time from IronPython

Hi,

System.TimeSpan does not add time when using Add:

>>> clr.AddReference('System')
>>> span = System.TimeSpan(1,0,0)
>>> span.ToString()
'01:00:00'
>>> hour = System.TimeSpan(1,0,0)
>>> hour.ToString()
'01:00:00'
>>> span.Add(hour)
<System.TimeSpan object at 0x000000000000002B [02:00:00]>
>>> span.ToString()
'01:00:00'

Should have been '02:00:00', because 1 hour is added.


Regards
Jan Rou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20091106/8e404c80/attachment.html>


More information about the Ironpython-users mailing list