Skip to content

Commit

Permalink
be consistent with tz offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
czue committed Jan 30, 2014
1 parent bc978ba commit 302a01b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions casexml/apps/stock/consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ def test_config(cls):
return cls(0, 0, 60)


def from_ts(dt): # damn this is ugly
def from_ts(dt):
# damn this is ugly
if isinstance(dt, datetime):
return dt
if len(dt) > 20 and dt.endswith('Z'): # deal with invalid timestamps (where are these coming from?)
return dt.replace(tzinfo=None)
if len(dt) > 20 and dt.endswith('Z'):
# deal with invalid timestamps (where are these coming from?)
dt = dt[:-1]
return dateparse.string_to_datetime(dt).replace(tzinfo=None)

to_ts = dateparse.json_format_datetime


Expand Down

0 comments on commit 302a01b

Please sign in to comment.