[IronPython] Problems with System.DateTime in RC1, and UtcNow in all 2.0 builds

Phil Vacca phil.vacca at gmail.com
Fri Oct 24 21:13:39 CEST 2008


I've been using each of the Betas of IPy 2, but now that I've switched
to RC1, I've got a probem.  The function get_UtcNow() doesn't seem to
exist in the RC.  Also the UtcNow method seems to have a major problem
as well.  I am hoping this is related to my own usage, and not to the
IPy build!

At the interpreter "from System.DateTime import get_UtcNow" fails
under the current RC (ipy.exe fileversion 2.0.11020.0), but works fine
from beta 5 (ipy.exe fileversion 2.0.10310.5).

The error I get reads:
  File "<stdin>", line 1, in <module>
ImportError: Cannot import name get_UtcNow

running "dir( System.DateTime )" shows confirming results.  The "get_"
functions just don't appear to be in there...

So, I tried just using the System.DateTime UtcNow method.
Unfortunately, it seems to only work once.  By this I mean that it
returns the correct time for UtcNow at import, but then every
subsequent call returns the SAME initialized time.  This behavior is
consistent at least against Beta 4 & 5, as well as the RC.

I ran the following code at the beta 5 interpreter and got these results:
import System
from System.DateTime import UtcNow, get_UtcNow

def problem():
    print UtcNow, get_UtcNow()
    print long(sum([i for i in range(10000000)])) ## waste some cycles
    print UtcNow, get_UtcNow()

def noProblem():
    print System.DateTime.UtcNow, get_UtcNow()
    print long(sum([i for i in range(10000000)])) ## waste some cycles
    print System.DateTime.UtcNow, get_UtcNow()

>>> problem()
10/24/2008 7:11:21 PM 10/24/2008 7:11:28 PM
10/24/2008 7:11:21 PM 10/24/2008 7:11:32 PM
>>> noProblem()
10/24/2008 7:11:43 PM 10/24/2008 7:11:43 PM
10/24/2008 7:11:47 PM 10/24/2008 7:11:47 PM

Does anyone else observe this same behavior?


phil.vacca at gmail.com

More information about the Ironpython-users mailing list