[egenix-users] mx.DateTime: Truncating fractional seconds

M.-A. Lemburg mal at lemburg.com
Sat Aug 9 11:44:52 CEST 2003


Steve Holden wrote:
> I've found that a number of platforms (Access, MS SQL Server) don't
> appear to like the fractional seconds part of a DateTime. The resulting
> warning messages are a little tedious (though I realise I *could*
> suppress them with the warnings module).
> 
> It's possible (though rather tedious) to reconstruct the object from its
> component attributes and truncate the seconds while so doing. I just
> wondered if anyone could think of a simpler way. I have this nagging
> feeling I'm overlooking the stunningly obvious.

I'm not sure what you mean. If it's the warnings that you get in
Python 2.3 from the time module functions if you pass in the
.tuple() value due to mxDateTime representing the seconds as
float, then this problem will be gone in 2.1.0 final (I decided
to make seconds in the .tuple() output an integer; the float
value is still available through the .seconds attribute).

If you're talking about the str() representation which includes
fractions, then the easiest way to get rid off the fractions
is use .strftime() which doesn't handle fractions of a second
by nature :-)

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Aug 09 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________



More information about the egenix-users mailing list