Skip to main content

Utilities for parsing time strings

Project description

Utilities for parsing time strings in Python.

Building and installation

Before installing chronos you will have to generate some of its modules as it is explained in Chronos readme Then, you can simply run

pip install bigml-chronos

Requirements

Python 2.7 and Python 3 are currently supported.

The basic third-party dependencies are isoweek and pytz. These libraries are automatically installed during the setup.

Running the tests

The tests will be run using nose, that is installed on setup. You can run the test suite simply by issuing

python setup.py nosetests

Basic methods

Chronos offers the following main functions:

  • With parse you can parse a date. You can specify a format name with format_name, a list of possible format names with format_names or not specify any format. In the last case, parse will try all the possible formats until it finds the correct one:

    from bigml_chronos import chronos
    chronos.parse("1969-W29-1", format_name="week-date")
    from bigml_chronos import chronos
    chronos.parse("1969-W29-1", format_names=["week-date", "week-date-time"])
    from bigml_chronos import chronos
    chronos.parse("7-14-1969 5:36 PM")
  • You can also find the format_name from a date with find_format:

    from bigml_chronos import parser
    chronos.find_format("1969-07-14Z")

Instead of the name of the format, you can also pass a string containing some Joda-Time directives.

from bigml_chronos import chronos
chronos.parse("1969-01-29", format_name="YYYY-MM-dd")

If both format_name and format_names are passed, it will try all the possible formats in format_names and format_name.

You can find all the supported formats, and an example for each one of them inside the test file.

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

bigml-chronos-0.4.2.tar.gz (15.3 kB view details)

Uploaded Source

File details

Details for the file bigml-chronos-0.4.2.tar.gz.

File metadata

  • Download URL: bigml-chronos-0.4.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.8

File hashes

Hashes for bigml-chronos-0.4.2.tar.gz
Algorithm Hash digest
SHA256 5cae0a08a2646d7a49518ae87460d1438f453c4a40a5855d1412d87068898b3b
MD5 cce9a4807775eda5e4581589365c3fd8
BLAKE2b-256 7ef3fb563084ee9b1090f1cd9725ae0f1593ed60b6cee759e49996cee6a813c9

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