Skip to main content

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

Project description

Parse strings to objects of the datetime-module.

This module intends to make string-parsing to objects of the datetime-module as easy as possible while allowing a fine configuration about which kind of formats are supported.

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

Dokumentaion:

Please visit the documentation on readthedocs.org: https://timeparser.readthedocs.org/en/latest/index.html

Usage

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')
ValueError: couldn't parse 234405 as time
>>>
>>> timeparser.parsedatetime('24-04-13_23:44:05')
datetime.datetime(2013, 4, 24, 23, 44, 5)

Changes in v0.5

deprecated:

setToday, setEndian and the ENDIAN_XXX-globals will be removed. Furthermore DateFormats-constructor and -config-method won’t accept an endian-kwarg anymore. ENDIAN will be like TODAY exclusively a global setting. To change them use TODAY.set(year, month, day) and ENDIAN.set(key), while key is a string: ‘year’, ‘month’ or ‘day’, resp. shortcuts like ‘y’, ‘m’ or ‘d’.

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.5.2.tar.gz (7.0 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for timeparser-0.5.2.tar.gz
Algorithm Hash digest
SHA256 7f188d99ef1d3050d499e4724f8b375bdee250c4bb94b1aa6008fceeea8cf253
MD5 5f42345ac55042cabc5f4f50d3a42a44
BLAKE2b-256 190e24be9ea473457fbcd136b5a3df18bde09fcf4193a2916819c73846bd27d3

See more details on using hashes here.

Supported by

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