Skip to content

Instantly share code, notes, and snippets.

@simonswine
Last active October 30, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonswine/eecba71bd10a2852bb49de3e4c27e12c to your computer and use it in GitHub Desktop.
Save simonswine/eecba71bd10a2852bb49de3e4c27e12c to your computer and use it in GitHub Desktop.
Calculate the time range in cortex's weekly tables
from datetime import datetime,timedelta
from pytz import timezone
tz = timezone('America/Los_Angeles')
period = 7*24*3600
for index in range (2648, 2654):
index_from = datetime.fromtimestamp(index*period,tz=tz)
index_to = datetime.fromtimestamp((index+1)*period-1,tz=tz)
print ('index %d: from %s to %s' % (index, index_from.isoformat(), index_to.isoformat()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment