Skip to content

Instantly share code, notes, and snippets.

@cjauvin
Last active April 23, 2017 01: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 cjauvin/b4aa0a69170f30faf2b1d0fd673184da to your computer and use it in GitHub Desktop.
Save cjauvin/b4aa0a69170f30faf2b1d0fd673184da to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import datetime as dt
import json
import os
N_PER_BOX = 30
path = os.path.dirname(os.path.realpath(__file__))
with open('%s/truth.json' % path) as f:
a = json.load(f)
d0 = dt.datetime.strptime(
next(iter(a['n_remaining_at_date_before_morning_intake'].keys())),
'%Y-%m-%d'
)
n0 = next(iter(a['n_remaining_at_date_before_morning_intake'].values()))
n_days_since = (dt.datetime.today() - d0).days
n_should_remain = (n0 - n_days_since) % N_PER_BOX or N_PER_BOX
print('%d should remain in box before morning intake' % n_should_remain)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment