Skip to content

Instantly share code, notes, and snippets.

@zed
Created October 4, 2014 08:50
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 zed/8a541bd0ce43700bf729 to your computer and use it in GitHub Desktop.
Save zed/8a541bd0ce43700bf729 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""Test http://stackoverflow.com/a/13424528/4279"""
import sys
from datetime import datetime
from subprocess import check_output
# results from http://stackoverflow.com/a/13425515/4279
for line in """\
2012/01/15 11:15:22 -118.24368490000002 -> 03:13:12.380880
2012/01/15 11:15:22 -74.0059731 -> 06:10:09.342843
2012/01/15 11:15:22 -0.12623620000000002 -> 11:05:40.870809
2012/01/15 11:15:22 2.3509871 -> 11:15:35.416883
2012/01/15 11:15:22 37.617633 -> 13:36:39.640637
2012/01/15 11:15:22 116.407413 -> 18:51:49.518788
2012/01/15 11:15:22 139.6917064 -> 20:24:57.689878
""".splitlines():
argv, _, expected = map(str.strip, line.partition('->'))
date, time, longitude = argv.split()
expected = datetime.strptime(date + ' ' + expected, "%Y/%m/%d %H:%M:%S.%f")
got = check_output([sys.executable or 'python', 'mattexx.py'] + argv.split())
got = datetime.strptime(got.strip(), "%Y-%m-%d %H:%M:%S.%f")
print((got - expected).total_seconds())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment