diff --git a/persistent/_timestamp.c b/persistent/_timestamp.c index 56c3230..3b8bb35 100644 --- a/persistent/_timestamp.c +++ b/persistent/_timestamp.c @@ -202,15 +202,6 @@ TimeStamp_sec(TimeStamp *self) v = (self->data[4] * 16777216 + self->data[5] * 65536 + self->data[6] * 256 + self->data[7]); sec = SCONV * (double)v; - /* always round to 6 places for consistency with the Python version. - We really only record that level of precision anyway. */ -#if defined(_MSC_VER) && _MSC_VER <= 1600 - /* the windows compilers for Python 2.7 and 3.4 don't support C99 - round(). 1600 is visual studio 10, aka 2010, used for 3.4 */ - sec = floor((sec * 1000000.0) + 0.5) / 1000000.0; -#else - sec = round(sec * 1000000.0) / 1000000.0; -#endif return sec; } diff --git a/persistent/timestamp.py b/persistent/timestamp.py index cd99cbd..a031a72 100644 --- a/persistent/timestamp.py +++ b/persistent/timestamp.py @@ -53,6 +53,7 @@ def fromutc(self, dt): return dt def _makeUTC(y, mo, d, h, mi, s): + s = round(s, 6) # microsecond precision, to match the C implementation usec, sec = math.modf(s) sec = int(sec) usec = int(usec * 1e6) @@ -75,7 +76,7 @@ def _parseRaw(octets): day = a // (60 * 24) % 31 + 1 month = a // (60 * 24 * 31) % 12 + 1 year = a // (60 * 24 * 31 * 12) + 1900 - second = round(b * _SCONV, 6) #microsecond precision + second = b * _SCONV return (year, month, day, hour, minute, second)