Skip to content
Snippets Groups Projects
Commit 6e08aa26 authored by mads's avatar mads
Browse files

speed up to_unix

parent 2785c0a7
No related branches found
No related tags found
No related merge requests found
from datetime import datetime, date from datetime import datetime, date
import numpy as np import numpy as np
timestamp0 = datetime.utcfromtimestamp(0)
def to_unix(dateTime): def to_unix(dateTime):
return (dateTime - datetime.utcfromtimestamp(0)).total_seconds() #return dateTime.timestamp() + 3600
return (dateTime - timestamp0).total_seconds()
#return (dateTime - datetime.utcfromtimestamp(0)).total_seconds()
def from_unix_old(sec): def from_unix_old(sec):
...@@ -32,4 +35,4 @@ def from_unix(sec): ...@@ -32,4 +35,4 @@ def from_unix(sec):
if du not in day_dict: if du not in day_dict:
day_dict[du] = date.fromordinal(719163 + du).timetuple()[:3] day_dict[du] = date.fromordinal(719163 + du).timetuple()[:3]
y, m, d = zip(*[day_dict[d_] for d_ in d]) y, m, d = zip(*[day_dict[d_] for d_ in d])
return ([datetime(*ymdhmsu) for ymdhmsu in zip(y, m, d, H.tolist(), M.tolist(), S.tolist(), ms.tolist())]) return ([datetime(*ymdhmsu) for ymdhmsu in zip(y, m, d, H.tolist(), M.tolist(), S.tolist(), ms.tolist())])
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment