Skip to main content

python-module to parse strings to time-, date-, datetime- or timedelta-objects.

Project description

A python-module to parse strings to time-, date-, datetime- or timedelta-objects. A set of time-formats are automatically and string-specifically produced and applied. The first one fitting is used to parse the string. The collection of formats to produce are highly configurable. In the default- configuration parses nearly everything.

Latest Version

The latest version of this project can be found at : http://github.com/thomst/timeparser.

Installation

  • Option 1 : Install via pip

    pip install timeparser
  • Option 2 : If you have downloaded the source

    python setup.py install

Documentation

How to use?

>>> import timeparser
>>>
>>> timeparser.parsedate('24.4.13')
datetime.date(2013, 4, 24)
>>>
>>> timeparser.parsedate('24 Apr 2013')
datetime.date(2013, 4, 24)
>>>
>>> timeparser.parsetime('234405')
datetime.time(23, 44, 5)
>>>
>>> timeparser.TimeFormats.config(allow_no_sep=False)
>>> timeparser.parsetime('234405')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "timeparser.py", line 398, in parsetime
    raise ValueError("couldn't parse %s as time" % string)
ValueError: couldn't parse 234405 as time
>>>
>>> timeparser.parsedatetime('24-04-13_23:44:05')
datetime.datetime(2013, 4, 24, 23, 44, 5)

Reporting Bugs

Please report bugs at github issue tracker: https://github.com/thomst/timeparser/issues

Author

thomst <thomaslfuss@gmx.de> Thomas Leichtfuß

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

timeparser-0.2.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file timeparser-0.2.tar.gz.

File metadata

  • Download URL: timeparser-0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for timeparser-0.2.tar.gz
Algorithm Hash digest
SHA256 364763c1bb4c88cb6b2adc9d380519255ec777a71c4cc8404613a03f6d3014a8
MD5 0f3ee11f2420a1eed527009bc8ffd4e3
BLAKE2b-256 1da8df4ec5edab279c4eaaf1bebcfe6b0e26008c3f05c4ca43c495d1ee3117ef

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