System.TimeSpan can't add time from IronPython

View: New views
2 Messages — Rating Filter:   Alert me  

System.TimeSpan can't add time from IronPython

by Jan R-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Re: System.TimeSpan can't add time from IronPython

by Dino Viehland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

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@... [mailto:users-bounces@...] 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


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com