Skip to content

Instantly share code, notes, and snippets.

@heymatthenry
Last active January 4, 2016 20:29
Show Gist options
  • Select an option

  • Save heymatthenry/8674567 to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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