Last active
December 31, 2015 22:19
-
-
Save dmpayton/8052756 to your computer and use it in GitHub Desktop.
Parsing human datetime strings as a service [Hy + Flask]
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
(import [datetime [datetime]]) | |
(import [flask [Flask request]]) | |
(import [parsedatetime [parsedatetime]]) | |
(import [time]) | |
(setv app (Flask __name__)) | |
(setv cal (parsedatetime.Calendar)) | |
(with-decorator (app.route "/") | |
(defn parse [] (do | |
(setv t (first (cal.parse (request.args.get "d")))) | |
(setv ts (time.mktime t)) | |
(setv dt (datetime.fromtimestamp ts)) | |
(dt.isoformat)))) | |
(if (= __name__ "__main__") | |
(app.run)) |
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
Flask==0.10.1 | |
hy==0.9.11 | |
parsedatetime==1.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment