esdateutil


Nameesdateutil JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryElasticsearch datemath and dateformat parsing library. Zero dependencies
upload_time2024-10-26 23:03:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.3
licenseCopyright (c) 2024 Matthew Murr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords elasticsearch elastic es datemath parser date format
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # esdateutil

Provides utilities for handling dates like how Elasticsearch does.

In particular:
 - Datemath parsing and evaluation ([ES Datemath Docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math))
 - Datetime string format parsing ([ES Dateformat Docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html))

The goals of this project are:
 - Be as close to Elasticsearch behaviour as Python makes sensible.
 - Require no runtime dependencies.
 - Customizability; most functionality should be parameterizable.

## Installation

esdateutil is on [PyPI](https://pypi.org/project/esdateutil/) and can be
downloaded via pip: `pip install esdateutil`

You can also just copy and use the bits you need. Because there are no
dependencies and not a lot of code the whole library is just 2 files and an
`__init__` totalling O(100s) LOC. Output for 1.0.0 from
[scc](https://github.com/boyter/scc):

```
$ ssc esdateutil
────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code
────────────────────────────────────────────────────────────────────
Python                       3       533       92        59      382
────────────────────────────────────────────────────────────────────
```

## Usage

### Basic Usage
```py
>>> from datetime import datetime
>>> datetime.now() # now is as below for all examples
datetime.datetime(2024, 9, 24, 8, 36, 17, 503027)

>>> from esdateutil import datemath, dateformat

>>> df = dateformat.DateFormat() # defaults to strict_date_optional_time||epoch_millis
>>> df.parse("2024-09-24T08:36Z") # strict_date_optional_time
datetime.datetime(2024, 9, 24, 08, 36, tzinfo=datetime.timezone.utc)
>>> df.parse("1727163377503") # epoch_millis
datetime.datetime(2024, 9, 24, 8, 36, 17, 503000)

>>> dm = datemath.DateMath()
>>> dm.eval("now-5m/h") # now minus 5 minutes rounded to the hour
datetime.datetime(2024, 9, 24, 8, 0)
>>> dm.eval("2024-09-24||-5m/h") # absolute time minus 5 minutes rounded to the hour
datetime.datetime(2024, 9, 23, 23, 0)
```

### Configuration Options

#### Dateformat

DateFormat objects are for parsing strings representing datetimes, with support
for [Elasticsearch built-in formats](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats)
and [format syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#multiple-date-formats).
They take
any number of date format strings and on calling `DateMath.parse` will try each
of them sequentially against the string being parsed, returning the first that
matches. If the string doesn't match any of the given dateformats, it returns a
ValueError containing each dateformat's failure reason.

##### fmt & separator

The `fmt` argument to DateFormat can be a string separated by `separator` (default "||") or a list containing strings and functions.

`fmt` as a string behaves the same as
[Elasticsearch format strings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)
taking the same built-in format names except that custom formats use Python
strptime instead of Java DateTimeFormatter formatted strings.

`esdateutil` doesn't support the full list of built-in formats in the Elastic
documentation. To see the list of supported built-in formats:
```py
>>> from esdateutil import dateformat
>>> print(list(dateformat.DATE_FORMATS.keys()))
...
```
As of writing, esdateutil supports:
 - strict_date
 - date
 - strict_date_optional_time
 - date_optional_time
 - strict_date_optional_time_nanos (`*`)
 - epoch_millis
 - epoch_second

`*`: Only supports up to microsecond precision. See "Differences from
Elasticsearch" below

By default the DateFormat object uses the format `strict_date_optional_time||epoch_millis`, which is what Elasticsearch uses.

You can also configure the separator, e.g.:

```py
>>> from esdateutil import dateformat
>>> parser = dateformat.DateFormat("strict_date, epoch_seconds", separator=", ")
>>> parser.parse("1729972832")
```

##### tzinfo

`tzinfo` can be set to a Python `timezone` instance which will be set on any
returned `datetime` instances from `DateMath.parse`. If the string being parsed
contains timezone information and the format sets that, this is used instead of
the tzinfo value. Format functions are responsible for this behaviour, so a
custom format can be used to alter this.

#### Datemath

DateMath objects can be used to evaluate or parse [datemath expressions](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math).
Simple as! You can configure most of the things that you might want to
configure, per the below instance options.

##### tzinfo

A `timezone` instance to add to evaluated `datetime`s. If the anchor parser
sets the tzinfo, that will be prefered. Defaults to None.

##### separator

Separator between an explicit anchor and the datemath expression. Defaults to
`"||"`. e.g.
```py
>>> from esdateutil import datemath
>>> dm = datemath.DateMath(separator=":")
>>> dm.eval("2024-12-24:+1d")
```

##### now_str

What to use as the anchor that gets the current datetime. Defaults to `"now"`.

```py
>>> from esdateutil import datemath
>>> dm = datemath.DateMath(now_str="sofort")
>>> dm.eval("sofort+1d")
```

##### now_fn

Function to use to get the current datetime. Takes an argument `tz` which is given as the arg `tzinfo`. Defaults to `lambda tz: datetime.now(tz)`.

##### date_fn

Function to use to parse non-now datetime anchors in `DateMath.eval` and `DateMath.parse`. Defaults to the equivalent of `dateformat.DateFormat.parse`, i.e. ES `strict_date_optional_time||epoch_millis`.

##### units_delta

Dictionary that maps datemath unit chars to functions to add and subtract that amount of time. Defaults to `datemath.UNITS_DELTA_DEFAULT` - see datemath.py for details.

##### units_round

Dictionary that maps datemath unit chars to fucntions to round to that duration of time. Defaults to `datemath.UNITS_ROUND_DOWN` - see datemath.py for details. `datemath` also provides `UNITS_ROUND_UP_MICROS` and `UNITS_ROUND_UP_MILLIS` for use with this argument, to round up to the highest time point in the given duration.

### Debug Logging

Debug logging can be set the same way as any Python lib using the `logging` stdlib library:

```py
import logging

import esdateutil

# To set globally:
logging.basicConfig(level=logging.DEBUG)

# Else to set for just the library logger:
handler = logging.StreamHandler()
esdateutil_logger = logging.getLogger("esdateutil")
esdateutil_logger.setLevel(logging.DEBUG)
esdateutil_logger.addHandler(handler)
```

## Development

The development scripts under `scripts/` are used to build and test the
library. They rely on pyenv and pyenv-virtualenv to work. Because testing is
done on 3.3 through 3.12+, you will need to build or download an old version of
openssl to build python 3.3 via pyenv. Read more about using
[pyenv](https://github.com/pyenv/pyenv) and [pyenv-virtualenv]().

The builds and tests are very simple, so feel free to do your own thing so long
as it works.

To run the test suite:

```sh
$ eval "$(pyenv init -)" # See https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv
$ pyenv install <py_ver>... # install all versions of python you need to test
$ scripts/tests.sh <py_ver>... # Run tests for given python versions
$ scripts/tests.sh # Run for all targeted python versions
```

Testing has only been performed on Linux. I expect everything to work on MacOS
and Windows. :v)

## Differences from Elasticsearch

One of the consequences of using Python's built-in datetime objects and
functions by default is that they can behave very differently from version to
version and from Elasticsearch defaults. Below are some of the most important
differences in functionality to be aware of.

 - The default time resolution in Elasticsearch is milliseconds, whereas in
   Python datetime it is microseconds. This shouldn't be important unless you
   are using datemath.UNITS_ROUND_UP_MICROS or another custom datemath round
   implementation. UNITS_ROUND_UP_MILLIS is provided as an alternative.
 - Elasticsearch has optional support for nanosecond precision - because Python
   datetimes use microsecond precision, we cannot support this completely. This
   impacts dateformat strict_date_option_time_nanos, which can still be used
   for microsecond precision instead of millis precision.
 - For custom dateformat strings we use strptime as a backup instead of [Java's time format strings](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html).

## Alternatives

### python-datemath

There is another Python project
[python-datemath](https://pypi.org/project/python-datemath/) for parsing
datemath expressions. This projects has different goals to esdateutil, the main
difference between them is that python-datemath parses a custom datemath
variant, whereas esdateutil.datemath adheres strictly to the Elasticsearch
datemath syntax. This means that although the syntax overlaps they will accept
and reject different strings.

In most cases, this probably doesn't matter. See the table below for a specific
feature difference breakdown.

| Difference          | esdateutil.datemath                                                                                                                    | python-datemath                                                                                                                                                                                                                                                                                                                |
| -----------         | ----------                                                                                                                             | ---------------                                                                                                                                                                                                                                                                                                                |
| Syntax              | Accepts and rejects same syntax as Elasticsearch. Unit chars are configurable.                                                         | Allows additional uppercase unit chars (Y for year, W for week, D for day, S for second), allows long-form units (e.g. `seconds`, `days`), allows fractional durations (e.g. +1.2d), does not allow missing number (e.g. +y vs +1y), treats expressions without anchors as having `now` (e.g. `+2d` is equivalent to `now+2d`) |
| Date String Support | Accepts the equivalent of `strict_date_optional_time\|\|epoch_millis` by default. Date parser can be overwritten by a user function.   | Accepts epoch seconds or all formats supported by arrow.get by default.                                                                                                                                                                                                                                                        |
| Date Types          | Uses Python's built-in datetime, timedelta, and timezone types for all date operations.                                                | Uses arrow's Arrow type for all operations. This can be converted to a datetime.                                                                                                                                                                                                                                               |
| Dependencies        | 0 runtime dependencies. 5 build dependencies (pyenv, pyenv-virtualenv, build, setuptools, wheel).                                      | 4 runtime dependenices, including transitive dependencies: arrow --> python-dateutil --> six + types-python-dateutil. 47 build dependencies.                                                                                                                                                                                   |
| Version Support     | Supports Python 3.3+                                                                                                                   | Supports Python 3.8+ with arrow 1.0.3+. Previous versions support 2.7 and 3.x                                                                                                                                                                                                                                                  |
| Performance         | Processes 1 million datemath strings in 11.39s On My Machine(TM). See profiling/ for details and to reproduce.                         | Processes 1 million datemath strings in 103.39s On My Machine(TM). See profiling/ for details and to reproduce.                                                                                                                                                                                                                |
| Type Hints          | No type hints.                                                                                                                         | Strict type checking with inline types.                                                                                                                                                                                                                                                                                        |
| Timezones           | Returns tz-unaware datetimes by default, unless tzinfo is given as an argument or timezone details are in a datestring.                | Assumes datetimes are UTC by default, unless tz is provided in a date string or given as a string argument.                                                                                                                                                                                                                    |
| Options             | https://git.sr.ht/~murr/esdateutil/tree/master/item/esdateutil/datemath.py#L79                                                         | https://github.com/nickmaccarthy/python-datemath/blob/master/datemath/helpers.py#L85                                                                                                                                                                                                                                           |
| Licence             | MIT                                                                                                                                    | Apache 2.0                                                                                                                                                                                                                                                                                                                     |

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "esdateutil",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.3",
    "maintainer_email": null,
    "keywords": "elasticsearch, elastic, es, datemath, parser, date, format",
    "author": null,
    "author_email": "Matthew Murr <matt@murr.dev>",
    "download_url": "https://files.pythonhosted.org/packages/64/a1/f5e88ab042bf9871a681f8400959340ae4e247e108c27ce5da1aa8b184db/esdateutil-1.0.1.tar.gz",
    "platform": null,
    "description": "# esdateutil\n\nProvides utilities for handling dates like how Elasticsearch does.\n\nIn particular:\n - Datemath parsing and evaluation ([ES Datemath Docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math))\n - Datetime string format parsing ([ES Dateformat Docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html))\n\nThe goals of this project are:\n - Be as close to Elasticsearch behaviour as Python makes sensible.\n - Require no runtime dependencies.\n - Customizability; most functionality should be parameterizable.\n\n## Installation\n\nesdateutil is on [PyPI](https://pypi.org/project/esdateutil/) and can be\ndownloaded via pip: `pip install esdateutil`\n\nYou can also just copy and use the bits you need. Because there are no\ndependencies and not a lot of code the whole library is just 2 files and an\n`__init__` totalling O(100s) LOC. Output for 1.0.0 from\n[scc](https://github.com/boyter/scc):\n\n```\n$ ssc esdateutil\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nLanguage                 Files     Lines   Blanks  Comments     Code\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nPython                       3       533       92        59      382\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n```\n\n## Usage\n\n### Basic Usage\n```py\n>>> from datetime import datetime\n>>> datetime.now() # now is as below for all examples\ndatetime.datetime(2024, 9, 24, 8, 36, 17, 503027)\n\n>>> from esdateutil import datemath, dateformat\n\n>>> df = dateformat.DateFormat() # defaults to strict_date_optional_time||epoch_millis\n>>> df.parse(\"2024-09-24T08:36Z\") # strict_date_optional_time\ndatetime.datetime(2024, 9, 24, 08, 36, tzinfo=datetime.timezone.utc)\n>>> df.parse(\"1727163377503\") # epoch_millis\ndatetime.datetime(2024, 9, 24, 8, 36, 17, 503000)\n\n>>> dm = datemath.DateMath()\n>>> dm.eval(\"now-5m/h\") # now minus 5 minutes rounded to the hour\ndatetime.datetime(2024, 9, 24, 8, 0)\n>>> dm.eval(\"2024-09-24||-5m/h\") # absolute time minus 5 minutes rounded to the hour\ndatetime.datetime(2024, 9, 23, 23, 0)\n```\n\n### Configuration Options\n\n#### Dateformat\n\nDateFormat objects are for parsing strings representing datetimes, with support\nfor [Elasticsearch built-in formats](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats)\nand [format syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html#multiple-date-formats).\nThey take\nany number of date format strings and on calling `DateMath.parse` will try each\nof them sequentially against the string being parsed, returning the first that\nmatches. If the string doesn't match any of the given dateformats, it returns a\nValueError containing each dateformat's failure reason.\n\n##### fmt & separator\n\nThe `fmt` argument to DateFormat can be a string separated by `separator` (default \"||\") or a list containing strings and functions.\n\n`fmt` as a string behaves the same as\n[Elasticsearch format strings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)\ntaking the same built-in format names except that custom formats use Python\nstrptime instead of Java DateTimeFormatter formatted strings.\n\n`esdateutil` doesn't support the full list of built-in formats in the Elastic\ndocumentation. To see the list of supported built-in formats:\n```py\n>>> from esdateutil import dateformat\n>>> print(list(dateformat.DATE_FORMATS.keys()))\n...\n```\nAs of writing, esdateutil supports:\n - strict_date\n - date\n - strict_date_optional_time\n - date_optional_time\n - strict_date_optional_time_nanos (`*`)\n - epoch_millis\n - epoch_second\n\n`*`: Only supports up to microsecond precision. See \"Differences from\nElasticsearch\" below\n\nBy default the DateFormat object uses the format `strict_date_optional_time||epoch_millis`, which is what Elasticsearch uses.\n\nYou can also configure the separator, e.g.:\n\n```py\n>>> from esdateutil import dateformat\n>>> parser = dateformat.DateFormat(\"strict_date, epoch_seconds\", separator=\", \")\n>>> parser.parse(\"1729972832\")\n```\n\n##### tzinfo\n\n`tzinfo` can be set to a Python `timezone` instance which will be set on any\nreturned `datetime` instances from `DateMath.parse`. If the string being parsed\ncontains timezone information and the format sets that, this is used instead of\nthe tzinfo value. Format functions are responsible for this behaviour, so a\ncustom format can be used to alter this.\n\n#### Datemath\n\nDateMath objects can be used to evaluate or parse [datemath expressions](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math).\nSimple as! You can configure most of the things that you might want to\nconfigure, per the below instance options.\n\n##### tzinfo\n\nA `timezone` instance to add to evaluated `datetime`s. If the anchor parser\nsets the tzinfo, that will be prefered. Defaults to None.\n\n##### separator\n\nSeparator between an explicit anchor and the datemath expression. Defaults to\n`\"||\"`. e.g.\n```py\n>>> from esdateutil import datemath\n>>> dm = datemath.DateMath(separator=\":\")\n>>> dm.eval(\"2024-12-24:+1d\")\n```\n\n##### now_str\n\nWhat to use as the anchor that gets the current datetime. Defaults to `\"now\"`.\n\n```py\n>>> from esdateutil import datemath\n>>> dm = datemath.DateMath(now_str=\"sofort\")\n>>> dm.eval(\"sofort+1d\")\n```\n\n##### now_fn\n\nFunction to use to get the current datetime. Takes an argument `tz` which is given as the arg `tzinfo`. Defaults to `lambda tz: datetime.now(tz)`.\n\n##### date_fn\n\nFunction to use to parse non-now datetime anchors in `DateMath.eval` and `DateMath.parse`. Defaults to the equivalent of `dateformat.DateFormat.parse`, i.e. ES `strict_date_optional_time||epoch_millis`.\n\n##### units_delta\n\nDictionary that maps datemath unit chars to functions to add and subtract that amount of time. Defaults to `datemath.UNITS_DELTA_DEFAULT` - see datemath.py for details.\n\n##### units_round\n\nDictionary that maps datemath unit chars to fucntions to round to that duration of time. Defaults to `datemath.UNITS_ROUND_DOWN` - see datemath.py for details. `datemath` also provides `UNITS_ROUND_UP_MICROS` and `UNITS_ROUND_UP_MILLIS` for use with this argument, to round up to the highest time point in the given duration.\n\n### Debug Logging\n\nDebug logging can be set the same way as any Python lib using the `logging` stdlib library:\n\n```py\nimport logging\n\nimport esdateutil\n\n# To set globally:\nlogging.basicConfig(level=logging.DEBUG)\n\n# Else to set for just the library logger:\nhandler = logging.StreamHandler()\nesdateutil_logger = logging.getLogger(\"esdateutil\")\nesdateutil_logger.setLevel(logging.DEBUG)\nesdateutil_logger.addHandler(handler)\n```\n\n## Development\n\nThe development scripts under `scripts/` are used to build and test the\nlibrary. They rely on pyenv and pyenv-virtualenv to work. Because testing is\ndone on 3.3 through 3.12+, you will need to build or download an old version of\nopenssl to build python 3.3 via pyenv. Read more about using\n[pyenv](https://github.com/pyenv/pyenv) and [pyenv-virtualenv]().\n\nThe builds and tests are very simple, so feel free to do your own thing so long\nas it works.\n\nTo run the test suite:\n\n```sh\n$ eval \"$(pyenv init -)\" # See https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv\n$ pyenv install <py_ver>... # install all versions of python you need to test\n$ scripts/tests.sh <py_ver>... # Run tests for given python versions\n$ scripts/tests.sh # Run for all targeted python versions\n```\n\nTesting has only been performed on Linux. I expect everything to work on MacOS\nand Windows. :v)\n\n## Differences from Elasticsearch\n\nOne of the consequences of using Python's built-in datetime objects and\nfunctions by default is that they can behave very differently from version to\nversion and from Elasticsearch defaults. Below are some of the most important\ndifferences in functionality to be aware of.\n\n - The default time resolution in Elasticsearch is milliseconds, whereas in\n   Python datetime it is microseconds. This shouldn't be important unless you\n   are using datemath.UNITS_ROUND_UP_MICROS or another custom datemath round\n   implementation. UNITS_ROUND_UP_MILLIS is provided as an alternative.\n - Elasticsearch has optional support for nanosecond precision - because Python\n   datetimes use microsecond precision, we cannot support this completely. This\n   impacts dateformat strict_date_option_time_nanos, which can still be used\n   for microsecond precision instead of millis precision.\n - For custom dateformat strings we use strptime as a backup instead of [Java's time format strings](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html).\n\n## Alternatives\n\n### python-datemath\n\nThere is another Python project\n[python-datemath](https://pypi.org/project/python-datemath/) for parsing\ndatemath expressions. This projects has different goals to esdateutil, the main\ndifference between them is that python-datemath parses a custom datemath\nvariant, whereas esdateutil.datemath adheres strictly to the Elasticsearch\ndatemath syntax. This means that although the syntax overlaps they will accept\nand reject different strings.\n\nIn most cases, this probably doesn't matter. See the table below for a specific\nfeature difference breakdown.\n\n| Difference          | esdateutil.datemath                                                                                                                    | python-datemath                                                                                                                                                                                                                                                                                                                |\n| -----------         | ----------                                                                                                                             | ---------------                                                                                                                                                                                                                                                                                                                |\n| Syntax              | Accepts and rejects same syntax as Elasticsearch. Unit chars are configurable.                                                         | Allows additional uppercase unit chars (Y for year, W for week, D for day, S for second), allows long-form units (e.g. `seconds`, `days`), allows fractional durations (e.g. +1.2d), does not allow missing number (e.g. +y vs +1y), treats expressions without anchors as having `now` (e.g. `+2d` is equivalent to `now+2d`) |\n| Date String Support | Accepts the equivalent of `strict_date_optional_time\\|\\|epoch_millis` by default. Date parser can be overwritten by a user function.   | Accepts epoch seconds or all formats supported by arrow.get by default.                                                                                                                                                                                                                                                        |\n| Date Types          | Uses Python's built-in datetime, timedelta, and timezone types for all date operations.                                                | Uses arrow's Arrow type for all operations. This can be converted to a datetime.                                                                                                                                                                                                                                               |\n| Dependencies        | 0 runtime dependencies. 5 build dependencies (pyenv, pyenv-virtualenv, build, setuptools, wheel).                                      | 4 runtime dependenices, including transitive dependencies: arrow --> python-dateutil --> six + types-python-dateutil. 47 build dependencies.                                                                                                                                                                                   |\n| Version Support     | Supports Python 3.3+                                                                                                                   | Supports Python 3.8+ with arrow 1.0.3+. Previous versions support 2.7 and 3.x                                                                                                                                                                                                                                                  |\n| Performance         | Processes 1 million datemath strings in 11.39s On My Machine(TM). See profiling/ for details and to reproduce.                         | Processes 1 million datemath strings in 103.39s On My Machine(TM). See profiling/ for details and to reproduce.                                                                                                                                                                                                                |\n| Type Hints          | No type hints.                                                                                                                         | Strict type checking with inline types.                                                                                                                                                                                                                                                                                        |\n| Timezones           | Returns tz-unaware datetimes by default, unless tzinfo is given as an argument or timezone details are in a datestring.                | Assumes datetimes are UTC by default, unless tz is provided in a date string or given as a string argument.                                                                                                                                                                                                                    |\n| Options             | https://git.sr.ht/~murr/esdateutil/tree/master/item/esdateutil/datemath.py#L79                                                         | https://github.com/nickmaccarthy/python-datemath/blob/master/datemath/helpers.py#L85                                                                                                                                                                                                                                           |\n| Licence             | MIT                                                                                                                                    | Apache 2.0                                                                                                                                                                                                                                                                                                                     |\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2024 Matthew Murr  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Elasticsearch datemath and dateformat parsing library. Zero dependencies",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://git.sr.ht/~murr/esdateutil/tree/master/item/README.md",
        "Homepage": "https://git.sr.ht/~murr/esdateutil",
        "Repository": "https://git.sr.ht/~murr/esdateutil"
    },
    "split_keywords": [
        "elasticsearch",
        " elastic",
        " es",
        " datemath",
        " parser",
        " date",
        " format"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "692d8a12a299a5ffaa66b0252c3e73d20d579c697d9296d302cca3380ab48c2c",
                "md5": "65f0a595707d93b55a3ed56687bc7351",
                "sha256": "36a5f089acfc0dba8d4069e12956efb8dbd28e6bbf809da9d80e4b2465b2eb1c"
            },
            "downloads": -1,
            "filename": "esdateutil-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "65f0a595707d93b55a3ed56687bc7351",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.3",
            "size": 13243,
            "upload_time": "2024-10-26T23:03:00",
            "upload_time_iso_8601": "2024-10-26T23:03:00.003448Z",
            "url": "https://files.pythonhosted.org/packages/69/2d/8a12a299a5ffaa66b0252c3e73d20d579c697d9296d302cca3380ab48c2c/esdateutil-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64a1f5e88ab042bf9871a681f8400959340ae4e247e108c27ce5da1aa8b184db",
                "md5": "5ad53cdeea9927a295ce86b81a397d16",
                "sha256": "80b5d1543278bab1a039a01093c476f2bc717dc9dfea062d0b185ebad05a0c03"
            },
            "downloads": -1,
            "filename": "esdateutil-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5ad53cdeea9927a295ce86b81a397d16",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.3",
            "size": 19779,
            "upload_time": "2024-10-26T23:03:01",
            "upload_time_iso_8601": "2024-10-26T23:03:01.721362Z",
            "url": "https://files.pythonhosted.org/packages/64/a1/f5e88ab042bf9871a681f8400959340ae4e247e108c27ce5da1aa8b184db/esdateutil-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 23:03:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "esdateutil"
}
        
Elapsed time: 0.44769s