datetime-parser


Namedatetime-parser JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/swimlane/datetime-parser
SummaryParse common datetime formats and a custom relative time format into a Pendulum object.
upload_time2024-07-03 16:26:40
maintainerNone
docs_urlNone
authorSwimlane
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datetime-parser

datetime can be many different formats and often we want to express a time relative 
to the current time, such as `10 minutes ago`. This module is able to handle all datetime formats
as well as our custom relative time format.

### Relative datetime format:
```
For the current time:
    now
Any other time:
    (+/-)(integer) (milliseconds|seconds|minutes|days|weeks|months|years)
    
examples:
    now
    -1 months
    +3 days
    -123 seconds
```

## Parse Datetime
To parse a datetime (not including relative time), you can use the `try_parse_dt` function. This
will return a pendulum object
```python
from datetime_parser import try_parse_dt

example = "2020-02-02 10:10:10"
example_obj = try_parse_datetime(example)
```

## Parse Relavite Time
To parse a datetime or relative datetime, use `is_datetime`.
```python
from datetime_parser import is_datetime

example = "-5 minutes"
example_obj = is_datetime(example)
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/swimlane/datetime-parser",
    "name": "datetime-parser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Swimlane",
    "author_email": "info@swimlane.com",
    "download_url": "https://files.pythonhosted.org/packages/90/a1/54e942c89ad39a82a6ddc36181d045a3e98e3507e7aac8f5898e1a84ac2a/datetime-parser-1.1.0.tar.gz",
    "platform": null,
    "description": "# datetime-parser\n\ndatetime can be many different formats and often we want to express a time relative \nto the current time, such as `10 minutes ago`. This module is able to handle all datetime formats\nas well as our custom relative time format.\n\n### Relative datetime format:\n```\nFor the current time:\n    now\nAny other time:\n    (+/-)(integer) (milliseconds|seconds|minutes|days|weeks|months|years)\n    \nexamples:\n    now\n    -1 months\n    +3 days\n    -123 seconds\n```\n\n## Parse Datetime\nTo parse a datetime (not including relative time), you can use the `try_parse_dt` function. This\nwill return a pendulum object\n```python\nfrom datetime_parser import try_parse_dt\n\nexample = \"2020-02-02 10:10:10\"\nexample_obj = try_parse_datetime(example)\n```\n\n## Parse Relavite Time\nTo parse a datetime or relative datetime, use `is_datetime`.\n```python\nfrom datetime_parser import is_datetime\n\nexample = \"-5 minutes\"\nexample_obj = is_datetime(example)\n```\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Parse common datetime formats and a custom relative time format into a Pendulum object.",
    "version": "1.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/swimlane/datetime-parser/issues",
        "Homepage": "https://github.com/swimlane/datetime-parser"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6004ee12476c7acc60fb1f83eb2e63e33a44963526e7f4d675650e37b94e6dc6",
                "md5": "fac372cf5bf6d0b219abac6ce0c7e10d",
                "sha256": "b8c06ec53e7ae5f69508ef04ff3a20f3d6e6b52095df2f6e32d78b5232e174d0"
            },
            "downloads": -1,
            "filename": "datetime_parser-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fac372cf5bf6d0b219abac6ce0c7e10d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6181,
            "upload_time": "2024-07-03T16:26:38",
            "upload_time_iso_8601": "2024-07-03T16:26:38.675904Z",
            "url": "https://files.pythonhosted.org/packages/60/04/ee12476c7acc60fb1f83eb2e63e33a44963526e7f4d675650e37b94e6dc6/datetime_parser-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "90a154e942c89ad39a82a6ddc36181d045a3e98e3507e7aac8f5898e1a84ac2a",
                "md5": "bd2c1b54332eae4ea513f825d63f5864",
                "sha256": "c0e08565f4832ca67b3ab01c0f834f8acc65b85b71a288773848c04ff83035e7"
            },
            "downloads": -1,
            "filename": "datetime-parser-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bd2c1b54332eae4ea513f825d63f5864",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5654,
            "upload_time": "2024-07-03T16:26:40",
            "upload_time_iso_8601": "2024-07-03T16:26:40.141446Z",
            "url": "https://files.pythonhosted.org/packages/90/a1/54e942c89ad39a82a6ddc36181d045a3e98e3507e7aac8f5898e1a84ac2a/datetime-parser-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-03 16:26:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "swimlane",
    "github_project": "datetime-parser",
    "github_not_found": true,
    "lcname": "datetime-parser"
}
        
Elapsed time: 0.29138s