Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Very flexible date parsing and normalization utilities

Project description

Date parsing and normalization utilities based on FlexiDate.

To parse dates use parse, e.g.:

from flexidate import parse
parse('1890') -> FlexiDate(year=u'1890')
parse('1890?') -> FlexiDate(year=u'1890', qualifier='Uncertainty: 1890?')

Once you have a FlexiDate you can get access to attributes (strings of course …):

from flexidate import parse
fd = parse('Jan 1890')
fd.year # u'1890'
fd.month # u'01'

Note how all fields are retained as strings – this is the only way to not lose information.

However, it’s easy to convert to other forms:

fd.as_float() # 1890
fd.as_datetime() # datetime(1890,01,01)

Background

FlexiDate is focused on supporting:

  1. Dates outside of Python (or DB) supported period (esp. dates < 0 AD)
  2. Imprecise dates (c.1860, 18??, fl. 1534, etc)
  3. Normalization of dates to machine processable versions
  4. Sortable in the database (in correct date order)

Flexidate builds on the excellent dateutil though it can be used without it.

For more information see: http://www.rufuspollock.org/2009/06/18/flexible-dates-in-python/

Developers

Tests can be found in test_flexidate.py.

Patches are welcome - please include additional tests where relevant.

Project details


Release history Release notifications

This version
History Node

1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
flexidate-1.0.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Source None Oct 11, 2012

Supported by

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