Skip to main content
Latest PyPI version Number of PyPI downloads Test bda.intellidatetime

bda.intellidatetime

Overview

bda.intellidatetime provides a converter for date and time input to python datetime.datetime objects.

The input format is definded by a locale2pattern mapping and is provided by a seperate interface.

Currently provided locales are:

  • en

  • de

  • fr

  • es

  • uk

  • it

  • cs

  • and the special locale iso, which is used as default.

Example

Use the convert function:

>>> from bda.intellidatetime import convert
>>> convert('1.1.08', locale='de')
datetime.datetime(2008, 1, 1, 0, 0)

API

The signature of bda.intellidatetime.convert looks like so:

def convert(date, time=None, tzinfo=None, locale='iso'):
    """Convert the input to a datetime object.

    The convert function accepts strings and tries to parse out Date and
    Time information as follows:
      * First try to get the localized datetime pattern information
      * If no one is found, a default pattern is used.
      * Parse the input by the definitions of the localized datetime pattern
      * Create a datetime object and return it

    The 'intelligence' is defined by following behaviour:

    Date:
      * If only one value is found f.e. '1', this value is handled as the
        day value, for month and for year the current ones are used.
      * Respective, if two values are given, they are handled as day and
        month, year is auto completed with the current year.
      * 3 values are a complete date information, if year is a 2-character
        string, it is handled as year in the current century
      * as limiters are all non-numeric values accepted
      * date input can be done without limiters, therefor all characters
        must be numbers, and the string length must be either 2, 4, 6 or 8
        characters. 2 characters define the day, 4 characters the day and
        the month, 6 characters day, month and the year of the current
        century and 8 characters define a complete date.

    Time:
      * If time is None, time is set to 00:00
      * if time is a 2-character string, it is handled as the hour, minutes
        are defined as 00
      * time input can be done without a limiter, therefor time must be an
        all numeric 4-character string, the first 2 chars are handled as
        hour, the second 2 chars as minute.
      * as limiter are all non-numeric values accepted
      * seconds are never computed and are therefor ALWAYS handled as '00'

    Limiters can be any 1 or more character non numeric values. An input
    can look like ``  %_2008 1 abcde 5 ---`` and is still valid and with
    default locale converted to ``datetime.datetime(2008, 1, 5, 0, 0)``.

    If parsing of the input values is not possible or converting the parsed
    values to numeric values is not possible or the valid date and time
    range falls out of scope, a ``DateTimeConversionError`` is raised.

    @param date - a date as string
    @param time - a time as string
    @param tzinfo - a tzinfo object to be considered, defaults to None. If
                    given the date and time taken as in the given timezone.
                    If the timezone is DST-aware time will be normalized
                    for DST/non-DST.
    @param locale - a locale name, which is used to determine the date and
                    time patterns. There exists a special locale named
                    'iso', which is default and expects the input in ISO
                    format.
    @return datetime - datetime.datetime object
    @raise DateTimeConversionError - if conversion fails
    """

Licence

  • Simplified BSD

Contributors

  • Robert Niederreiter (Author)

  • Jens W. Klein

Changes

2.0.0 (2026-10-31)

  • Drop the Python 2 remnants: IS_PY2 and STRING_TYPES in bda.intellidatetime.converter, u'' prefixes and class X(object). Behaviour unchanged. [rnix]

  • Use pytest as test runner. Move the tests to bda.intellidatetime.tests and test the tzinfo normalization. The tests no longer depend on the wording of the datetime error message, which changed in Python 3.14. [rnix]

  • Sort the imports with ruff (one per line, from imports first, no sections) and format the code with ruff format (90 characters per line, single quotes). [rnix]

  • Add Makefile (mxmake) with qa.ruff, qa.test and qa.coverage domains, pin the ruff configuration in pyproject.toml and add a GitHub Actions test workflow. [rnix]

  • Move the changelog from README.rst to CHANGES.rst. [rnix]

  • Refactor package layout to use pyproject.toml and implicit namespace packages. [rnix]

  • Drop Python 2 support. Python >= 3.10 is required. [rnix]

1.4 (2022-12-05)

  • Release wheel. [rnix]

1.3 (2018-07-16)

  • Python 3 compatibility. [rnix]

  • Convert doctests to unittests. [rnix]

1.2.2

  • Package cleanup. [rnix, 2017-03-29]

1.2.1

  • fix MANIFEST.in to include configure.zcml in release [jensens, 2013-09-23]

1.2

  • Use zope.interface.implementer instead of zope.interface.implements. [rnix, 2012-05-18]

1.1

  • Provide convenience convert function. [rnix, 2010-05-08]

  • Change package structure. [rnix, 2010-05-08]

  • Move tests into seperate file. [rnix, 2010-05-08]

  • Change signature of converter. could now be registered as utility as well if desired. [rnix, 2010-05-08]

  • Adapter pattern deprecated. [rnix, 2010-05-08]

1.0

  • Make it work [rnix, jensens]

License

Copyright (c) 2010-2022, BlueDynamics Alliance, Austria All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the BlueDynamics Alliance nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY BlueDynamics Alliance AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BlueDynamics Alliance BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Metadata

Release files for bda.intellidatetime 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bda.intellidatetime 2.0.0
File Size Uploaded Provenance Actions
bda_intellidatetime-2.0.0.tar.gz 9.4 kB Without provenance Details for bda_intellidatetime-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bda.intellidatetime 2.0.0
File Interpreter ABI Platform Actions
bda_intellidatetime-2.0.0-py3-none-any.whl Python 3 none any Details for bda_intellidatetime-2.0.0-py3-none-any.whl

Total release size: 20.9 kB

Release files / bda_intellidatetime-2.0.0.tar.gz

Download URL bda_intellidatetime-2.0.0.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9aec4211da03d57239d2ad1d8676cb5811067edda9b82c54224f42623971f04b
BLAKE2b-256 checksum
How to use checksums
a080f635fb74698f15ef8d19e09b5c6102e77c52466e01e68751b835d59e1c6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / bda_intellidatetime-2.0.0-py3-none-any.whl

Download URL bda_intellidatetime-2.0.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4047fd994fb8c25f7aad15f833020d3049f8c1bee60ee4c116da5c83dac2c89
BLAKE2b-256 checksum
How to use checksums
d6a584b3e8bcaf71b90864ba8da9cb90623fd5596d33c839dc4cd422325ac8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for bda.intellidatetime 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page