Last active
January 4, 2016 20:29
-
-
Save heymatthenry/8674567 to your computer and use it in GitHub Desktop.
Script to be run as a TextExpander snippet that creates a due date tag from a natural language date string.
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/local/bin/python | |
| # Requires parsedatetime module: | |
| # https://github.com/bear/parsedatetime | |
| import parsedatetime as pdt | |
| natLangDateStr = "%filltext:name=date:default=today%" | |
| dt = pdt.Calendar().parse(natLangDateStr)[0] | |
| formattedDate = "{month}-{day}-{year}".format(month=dt.tm_mon, | |
| day=dt.tm_mday, year=dt.tm_year) | |
| print "@due(" + formattedDate + ")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment