Skip to content

Commit

Permalink
Drop rounding from both implementations of the second() accessor. The…
Browse files Browse the repository at this point in the history
… Python timeTime() still needs to round to match C.
  • Loading branch information
jamadden committed Aug 6, 2018
1 parent e00b287 commit 5c70f32
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
9 changes: 0 additions & 9 deletions persistent/_timestamp.c
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion persistent/timestamp.py
Expand Up @@ -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)
Expand All @@ -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)


Expand Down

0 comments on commit 5c70f32

Please sign in to comment.