# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['utcnow']

package_data = \
{'': ['*']}

setup_kwargs = {
    'name': 'utcnow',
    'version': '0.1.1',
    'description': 'Timestamps as opinionated RFC 3339 (Date and Time on the Internet) formatted strings',
    'long_description': '# `utcnow`\n[![pypi](https://badge.fury.io/py/utcnow.svg)](https://pypi.python.org/pypi/utcnow/)\n[![Made with Python](https://img.shields.io/pypi/pyversions/utcnow)](https://www.python.org/)\n[![Type hinted - mypy validated](https://img.shields.io/badge/typehinted-yes-teal)](https://github.com/kalaspuff/utcnow)\n[![MIT License](https://img.shields.io/github/license/kalaspuff/utcnow.svg)](https://github.com/kalaspuff/utcnow/blob/master/LICENSE)\n\n*Timestamps as RFC 3339 (Date and Time on the Internet) formatted strings with conversion from other timestamps in similar formats or from datetime objects or other date libraries that uses values convertable to strings and are compatible with RFC 3339. There\'s no other external dependencies required.*\n\nA convenient utility package for when you need to store RFC 3339 timestamps in a datastore as a string, adding it to a JSON response or using a shared and common standard in your log outputs. Example output in string format would be `"2021-02-18T08:24:48.382262Z"`.\n\nThis is not a fullblown date library at all – it\'s simple and basically it just output timestamps into the fixes length string format `YYYY-MM-DDTHH:mm:ss.uuuuuuZ` (or as `%Y-%m-%dT%H:%M:%SZ` as if used with `datetime.datetime.strftime`). Always uses UTC in output and always appends the UTC timezone as a `Z` to the string (instead of using `+00:00` or ` UTC`).\n\n## Transformation examples\n```python\n# This represents 20 minutes and 50.52 seconds after the 23rd hour of April 12th, 1985 in UTC.\nfrom = "1985-04-12T23:20:50.52Z"\nto = "1985-04-12T23:20:50.520000Z"\n\n# This represents 39 minutes and 57 seconds after the 16th hour of December 19th, 1996 with an offset of\n# -08:00 from UTC (Pacific Standard Time).  Note that this is equivalent to 1996-12-20T00:39:57Z in UTC.\nfrom = "1996-12-19T16:39:57-08:00"\nto = "1996-12-20T00:39:57.000000Z"\n\n# This represents the same instant of time as noon, January 1, 1937, Netherlands time. Standard time in the\n# Netherlands was exactly 19 minutes and 32.13 seconds ahead of UTC by law from 1909-05-01 through 1937-06-30.\nfrom = "1937-01-01T12:00:27.87+00:20"\nto = "1937-01-01T11:40:27.870000Z"\n\n# Examples of other formats of accepted inputs:\n#    from: "2021-02-18"                          =>    to: "2021-02-18T00:00:00.000000Z"\n#    from: "2021-02-18 01:00"                    =>    to: "2021-02-18T01:00:00.000000Z"\n#    from: "2021-02-18 03:00+01:00"              =>    to: "2021-02-18T02:00:00.000000Z"\n#    from: "2021-02-18-01:00"                    =>    to: "2021-02-18T01:00:00.000000Z"\n#    from: "2021-02-18+01:00"                    =>    to: "2021-02-17T23:00:00.000000Z"\n#    from: "2021-02-18T23:55"                    =>    to: "2021-02-18T23:55:00.000000Z"\n#    from: "2021-02-18T23:55:10"                 =>    to: "2021-02-18T23:55:10.000000Z"\n#    from: "2021-02-18T23:55:10.0"               =>    to: "2021-02-18T23:55:10.000000Z"\n#    from: "2021-02-18T23:55:10.0+05:00"         =>    to: "2021-02-18T18:55:10.000000Z"\n#    from: "2021-02-18T23:55:10.0-05:00"         =>    to: "2021-02-19T04:55:10.000000Z"\n#    from: "2021-02-18T23:55:10.550-05:00"       =>    to: "2021-02-19T04:55:10.550000Z"\n#    from: "2021-02-18 23:55:10.550+05:00"       =>    to: "2021-02-18T18:55:10.550000Z"\n#    from: "2021-02-18 23:55:10.550-01:00"       =>    to: "2021-02-19T00:55:10.550000Z"\n#    from: "2021-02-28 10:10:59.123987+00:00"    =>    to: "2021-02-28T10:10:59.123987Z"\n#    from: "2021-02-28 10:10:59.123987Z"         =>    to: "2021-02-28T10:10:59.123987Z"\n#    from: "2021-02-28 10:10:59.123987 UTC"      =>    to: "2021-02-28T10:10:59.123987Z"\n```\n\n## Installation with `pip`\nLike you would install any other Python package, use `pip`, `poetry`, `pipenv` or your weapon of choice.\n```\n$ pip install utcnow\n```\n\n\n## Usage and examples\n\n```python\n# Transform timestamps of many different formats to the same fixed length standard\n\nfrom utcnow import utcnow\nresult = utcnow.as_string("1984-08-01 13:38")\n# \'1984-08-01T13:38:00.000000Z\'\n```\n\n```python\n# RFC 3339 timestamps works as input – dates and datetimes – UTC will be assumed if timezone is left out\n\nfrom utcnow import utcnow\nresult = utcnow.as_string("2077-10-27")\n# \'2077-10-27T00:00:00.000000Z\'\n```\n\n```python\n# Simple exmple of converting a naive datetime value, assuming UTC\n\nimport datetime\nfrom utcnow import utcnow\ndt = datetime.datetime(1984, 8, 1, 13, 38, 0, 4711)\nresult = utcnow.as_string(dt)\n# \'1984-08-01T13:38:00.004711Z\'\n# for non-tz-aware datetimes, the same result would be returned by both:\n# 1. utcnow.as_string(dt)\n# 2. dt.strftime("%Y-%m-%dT%H:%M:%S.%fZ")\n```\n\n```python\n# It\'s also possible to transform datetime values with timezone offsets into timestamp strings\n\nimport datetime\nfrom utcnow import utcnow\ntz_EDT = datetime.timezone(offset=datetime.timedelta(hours=-4))\ndt = datetime.datetime(1997, 8, 4, 2, 14, tzinfo=tz_EDT)\nresult = utcnow.as_string(dt)\n# \'1997-08-04T06:14:00.000000Z\'\n# for timezone-aware datetimes, the same result would be returned by both:\n# 1. utcnow.as_string(dt)\n# 2. dt.astimezone(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")\n```\n\n```python\n# Or vice versa, transforming a timestamp string into a datetime object (with tzinfo set to UTC)\n\nfrom utcnow import utcnow\nresult = utcnow.as_datetime("1984-08-01T13:38:00.123450Z")\n# datetime.datetime(1984, 8, 1, 13, 38, 0, 123450, tzinfo=datetime.timezone.utc)\n```\n\n```python\n# Getting the current server time in UTC as a timestamp string\n\nimport utcnow\nutcnow.utcnow()\n# \'2021-02-18T08:24:48.382262Z\'\n# same thing can be accomplished using datetime and all of these calls returns the same str value:\n# 1. utcnow.utcnow()\n# 2. str(utcnow)\n# 3. str(utcnow.utcnow)\n# 4. utcnow.as_string()\n# 5. utcnow.utcnow.as_string()\n# 6. datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")\n# 7. datetime.datetime.utcnow().isoformat() + "Z"\n# 8. datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")\n```\n\n```python\n# Or getting the current time in UTC as a datetime object\n\nfrom utcnow import utcnow\nutcnow.as_datetime()\n# datetime.datetime(2021, 2, 18, 8, 24, 48, 382262, tzinfo=datetime.timezone.utc)\n# this is merely a convinience, as the same value would be returned by both:\n# 1. utcnow.as_datetime()\n# 2. datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)\n```\n\n```python\n# As described – current server timestamp as a RFC 3339 timestamp in UTC\n\nimport utcnow\nresult = str(utcnow)\n# \'2021-02-18T08:24:48.382262Z\'\n```\n\n```python\n# Easy way of adding the current timestamp to a JSON response\n\nimport json\nimport utcnow\nresult = json.dumps({"timestamp": str(utcnow), "status": 200})\n# \'{"timestamp": "2021-02-18T08:24:48.382262Z", "status": 200}\'\n```\n\n```python\n# Or just adding the current time in an f-string\n\nimport utcnow\nresult = f"Current server time is: {utcnow}"\n# \'Current server time is: 2021-02-18T08:24:48.382262Z\'\n```\n',
    'author': 'Carl Oscar Aaro',
    'author_email': 'hello@carloscar.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/kalaspuff/izakaya',
    'packages': packages,
    'package_data': package_data,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
