Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Convert fuzzy date to a datetime object.

Project description

Convert from fuzzy dates like “yesterday”, “2 weeks and 1 day ago”, “next wed”, “Jan 4”, etc., to a datetime object.

This is useful for processing command line arguments:

>>> from optparse import OptionParser
>>> import magicdate
>>> parser = OptionParser(option_class=magicdate.MagicDateOption)
>>> parser.add_option('-s', '--start', dest='start', type='magicdate', default=None)
>>> parser.add_option('-e', '--end', dest='end', type='magicdate', default='today')

Now you can pass options like “today”, “1996-01-01”, etc., to your program.

Inspired by Simon Willison’s dateparse.js.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for magicdate, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size magicdate-0.1.3-py2.5.egg (5.6 kB) File type Egg Python version 2.5 Upload date Hashes View hashes
Filename, size magicdate-0.1.3.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page