Skip to main content

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.

Download files

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

Source Distribution

magicdate-0.2.2.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file magicdate-0.2.2.tar.gz.

File metadata

  • Download URL: magicdate-0.2.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for magicdate-0.2.2.tar.gz
Algorithm Hash digest
SHA256 256f196eb328f01310db536026c477bd3b81cf796ea5e2918d26afb17834a8de
MD5 5c69ca5297a2d3b41a0adfa1527a3844
BLAKE2b-256 996893cc5ee8f323c7ca92ea51b50b0785f8b05912313220aa5fcb1767ee76ff

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 file

0.2.1

1 file

0.2

1 file

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page