File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ def is_naive(dt):
77 """ Determines if a given datetime.datetime is naive. """
88 return dt .tzinfo is None or dt .tzinfo .utcoffset (dt ) is None
99
10+ def total_seconds (delta ):
11+ """ Determines total seconds with python < 2.7 compat """
12+ # http://stackoverflow.com/questions/3694835/python-2-6-5-divide-timedelta-with-timedelta
13+ return (delta .microseconds + (delta .seconds + delta .days * 24 * 3600 ) * 1e6 ) / 1e6
1014
1115def guess_timezone (dt ):
1216 """ Attempts to convert a naive datetime to an aware datetime """
@@ -15,7 +19,7 @@ def guess_timezone(dt):
1519 # case, and then defaults to utc
1620
1721 delta = datetime .now () - dt
18- if delta . total_seconds () < 5 :
22+ if total_seconds (delta ) < 5 :
1923 # this was created using datetime.datetime.now()
2024 # so we are in the local timezone
2125 return dt .replace (tzinfo = tzlocal ())
Original file line number Diff line number Diff line change 1- VERSION = '0.4.3 '
1+ VERSION = '0.4.4 '
Original file line number Diff line number Diff line change 1- 0.4.3 / 2013-11-13
1+ 0.4.4 / November 21, 2013
2+ ------------------
3+ * add < python 2.7 compatibility by removing ` delta.total_seconds `
4+
5+ 0.4.3 / November 13, 2013
26------------------
37* added datetime serialization fix (alexlouden)
48
5- 0.4.2 / 2013-06-25
9+ 0.4.2 / June 26, 2013
610------------------
711* Added history.d change log
812* Merging https://github.com/segmentio/analytics-python/pull/14 to add support for lists and PEP8 fixes. Thanks https://github.com/dfee !
You can’t perform that action at this time.
0 commit comments