Skip to main content

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.

Source Distribution

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

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for magicdate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d92106f1f424d7c10d03d190fb2760a248773d8b8c78bf0f867dfa34daa712be
MD5 ca1cfce5a54f9087bdb6c47528a7a0b6
BLAKE2b-256 c3cf49893e334eab50f71b399b127521599fefa0d0fa9fff6515a5134260c5f8

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page