>> My problem is with dateutil's microsecond precision. An example: >> >>>>> date = '2009-01-11 03:55:23.255000' >>>>> d = dateutil.parser.parse(date) >>>>> d >> datetime.datetime(2009, 1, 11, 3, 55, 23, 254999) >> >> Note the microseconds of the datetime object are 254999, >> whereas the original date string given was 255000.
Just in case anyone is curios, this is a classic binary floating point issue: the 23.2550000 is being interpreted as floating point seconds, rather than as integer seconds and microseconds. 23.255 can not be exactly represented in binary floating point: >>> s = 23.255000 >>> s 23.254999999999999 >>> >>> s - int(s) 0.25499999999999901 >>> I suspect dateutils is fixed by either parsing out the seconds, or adding a round() to the above: >>> s = 23.255 >>> seconds = int(s) >>> microseconds = int(round((s-seconds)*1e6)) >>> seconds, microseconds (23, 255000) -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users