Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1125)

Unified Diff: dfdatetime/cocoa_time.py

Issue 337640043: [dfdatetime] Replace float with decimal for normalized timestamps. (Closed)
Patch Set: Replace float with decimal for normalized timestamps. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dfdatetime/delphi_date_time.py » ('j') | dfdatetime/time_elements.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dfdatetime/cocoa_time.py
diff --git a/dfdatetime/cocoa_time.py b/dfdatetime/cocoa_time.py
index ba5dca5597e6be59f1b09ffee7bfa40407b928eb..9de49cc6d025c94002e305c68bc8f7bbe33bdad3 100644
--- a/dfdatetime/cocoa_time.py
+++ b/dfdatetime/cocoa_time.py
@@ -3,6 +3,8 @@
from __future__ import unicode_literals
+import decimal
+
from dfdatetime import definitions
from dfdatetime import interface
@@ -61,7 +63,8 @@ class CocoaTime(interface.DateTimeValues):
"""
if self._normalized_timestamp is None:
if self._timestamp is not None:
- self._normalized_timestamp = self._timestamp - self._COCOA_TO_POSIX_BASE
+ self._SetNormalizedTimestamp(
+ decimal.Decimal(self._timestamp) - self._COCOA_TO_POSIX_BASE)
return self._normalized_timestamp
@@ -94,9 +97,9 @@ class CocoaTime(interface.DateTimeValues):
year, month, day_of_month, hours, minutes, seconds)
timestamp += self._COCOA_TO_POSIX_BASE
- timestamp = float(timestamp)
if microseconds is not None:
Joachim Metz 2018/03/13 04:37:54 this is a logic change I've undid these changes.
- timestamp += float(microseconds) / definitions.MICROSECONDS_PER_SECOND
+ timestamp += (float(microseconds) /
+ definitions.MICROSECONDS_PER_SECOND)
self._normalized_timestamp = None
self._timestamp = timestamp
« no previous file with comments | « no previous file | dfdatetime/delphi_date_time.py » ('j') | dfdatetime/time_elements.py » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b