Created
February 21, 2015 00:32
-
-
Save BenjaminVanRyseghem/21876407114dd55a1d97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import parsedatetime | |
import sys | |
from time import mktime | |
from datetime import datetime | |
AS_DATE_FORMAT = "%d/%m/%y" | |
string = sys.argv[1] | |
cal = parsedatetime.Calendar() | |
(val, code) = cal.parse(string) | |
# possible values for code | |
# 1 = date (with current time, as a struct_time) | |
# 2 = time (with current date, as a struct_time) | |
# 3 = datetime | |
dt = datetime.fromtimestamp(mktime(val)) | |
print dt.strftime(AS_DATE_FORMAT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pip install parsedatetime
may be require before this to workNote that
AS_DATE_FORMAT
may vary based on your machine localization.On my other machine, the correct value was
AS_DATE_FORMAT = "%A, %B %d, %Y %I:%M:%S %p"