{ "info": { "author": "Ken Hu", "author_email": "whosbacon@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "datetimeutc\r\n\r\nA Python datetime wrapper so we can forget about timezones\r\n\r\nA lightweight datetime utility library which wraps around the standard `datetime` module, with features from dateutil and pytz.\r\n\r\nIts purpose is to minimize the effort to convert datetime to/from UTC, a task I found myself doing too often while scaling web services and apps internationally.\r\n\r\nThis wrapper is designed under these datetime philosophy:\r\n\r\n1. datetime should always be timezone aware\r\n2. datetime should always be handled and stored in UTC time\r\n3. datetime should always default to UTC time\r\n4. datetime should not contain server local time\r\n5. timezone conversions should be done on client side\r\n\r\nInstall\r\n\r\n $ pip install datetimeutc\r\n\r\nUsage\r\n\r\nThe library provides thinly wrappers of datetime classes, e.g. datetime, date, and time.\r\n\r\nInstances of these class are created with timezone awareness in UTC time. Users can also pass in `None` or other timezone, which the library will automatically converts into UTC time.\r\n\r\n>>> from datetimeutc import Datetime, Date, Time\r\n>>> import pytz\r\n>>> d = Datetime(2016, 3, 21, 9, 20, 40)\r\nDatetime(2016, 3, 21, 9, 20, 40, tzinfo=)\r\n>>> Datetime(2016, 3, 21, 9, 20, 40, tzinfo=pytz.timezone('US/Eastern'))\r\nDatetime(2016, 3, 21, 14, 16, 40, tzinfo=)\r\n\r\nFunctions of datetime are all supported.\r\n\r\n>>> from datetimeutc import Datetime, Date, Time\r\n>>> Datetime.now()\r\nDatetime(2016, 3, 21, 9, 20, 40, 816025, tzinfo=)\r\n>>> Datetime.now().dst() \r\ndatetime.timedelta(0)\r\n>>> Datetime.now().timetuple()\r\ntime.struct_time(tm_year=2016, tm_mon=3, tm_mday=21, tm_hour=9, tm_min=7, tm_sec=47, tm_wday=0, tm_yday=81, tm_isdst=0)\r\n>>> Datetime.now().toordinal()\r\n736044\r\n>>> Datetime.now().isoweekday()\r\n1\r\n>>> Datetime.now().isoformat()\r\n'2016-03-21T09:08:17.488494+00:00'\r\n>>> Datetime.strptime('2016-03-21','%Y-%m-%d')\r\nDatetime(2016, 3, 21, 0, 0, tzinfo=)\r\n>>> datetimeutc.Datetime(2016, 3, 21, 9, 20, 40).astimezone(pytz.timezone('US/Eastern'))\r\ndatetime.datetime(2016, 3, 21, 5, 20, 40, tzinfo=)\r\n\r\nUtilities\r\n\r\nOther datetime functions are available for common tasks, e.g. converting to/from javascript timestamp\r\n\r\n>>> import datetimeutc, datetime\r\n>>> datetimeutc.to_utc(datetime.datetime.now())\r\ndatetime.datetime(2016, 3, 21, 9, 31, 8, 455166, tzinfo=)\r\n>>> d = datetimeutc.Datetime(2016, 3, 21, 9, 20, 40)\r\n>>> d\r\nDatetime(2016, 3, 21, 9, 20, 40, tzinfo=)\r\n>>> d.timestamp\r\n1458552040\r\n>>> d.jstimestamp \r\n1458552040000.0\r\n>>> datetimeutc.Datetime.from_jstimestamp(d.jstimestamp)\r\nDatetime(2016, 3, 21, 9, 20, 40, tzinfo=)", "description_content_type": null, "docs_url": "https://pythonhosted.org/datetimeutc/", "download_url": "https://github.com/whosken/datetimeutc", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://whosken.github.io/datetimeutc", "keywords": "datetime,timezone,utc", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "datetimeutc", "package_url": "https://pypi.org/project/datetimeutc/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/datetimeutc/", "project_urls": { "Download": "https://github.com/whosken/datetimeutc", "Homepage": "http://whosken.github.io/datetimeutc" }, "release_url": "https://pypi.org/project/datetimeutc/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Because why are we dealing with timezones?", "version": "0.1.1" }, "last_serial": 2068985, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d26bd168ae4bb1a511cc57b3b7068bca", "sha256": "4bc2ef9781bfb45e462672064bb1eb4f41ceda2d6e7232420548bc39ca0566c5" }, "downloads": -1, "filename": "datetimeutc-0.1.tar.gz", "has_sig": false, "md5_digest": "d26bd168ae4bb1a511cc57b3b7068bca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1903, "upload_time": "2016-03-21T09:04:25", "url": "https://files.pythonhosted.org/packages/3b/41/d35db61fb5488ee537dc3f4b174c9170e161bb66401fe6dfc7edfb90634c/datetimeutc-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a1c16ccdcb5e799377a4e0800d847324", "sha256": "8c15ca1be628ab27019077e9c08de2c2be3cf40762eaa59d7b2a37370cd8b8d1" }, "downloads": -1, "filename": "datetimeutc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a1c16ccdcb5e799377a4e0800d847324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1853, "upload_time": "2016-03-21T09:49:38", "url": "https://files.pythonhosted.org/packages/9d/54/a643836522896572896255950f6426ba84a4488325cb1dbbb28532ed852e/datetimeutc-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a1c16ccdcb5e799377a4e0800d847324", "sha256": "8c15ca1be628ab27019077e9c08de2c2be3cf40762eaa59d7b2a37370cd8b8d1" }, "downloads": -1, "filename": "datetimeutc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a1c16ccdcb5e799377a4e0800d847324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1853, "upload_time": "2016-03-21T09:49:38", "url": "https://files.pythonhosted.org/packages/9d/54/a643836522896572896255950f6426ba84a4488325cb1dbbb28532ed852e/datetimeutc-0.1.1.tar.gz" } ] }