{ "info": { "author": "Met Office", "author_email": "metomi@metoffice.gov.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Operating System :: OS Independent", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "isodatetime\n===========\n\n[![Build Status](https://travis-ci.org/metomi/isodatetime.svg?branch=master)](https://travis-ci.org/metomi/isodatetime)\n[![codecov](https://codecov.io/gh/metomi/isodatetime/branch/master/graph/badge.svg)](https://codecov.io/gh/metomi/isodatetime)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.597555.svg)](https://doi.org/10.5281/zenodo.597555)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/1fd1147b75474d4d9a0f64bececf3bb5)](https://www.codacy.com/app/metomi/isodatetime?utm_source=github.com&utm_medium=referral&utm_content=metomi/isodatetime&utm_campaign=Badge_Grade)\n[![PYPI Badge](https://img.shields.io/pypi/v/isodatetime.svg)](https://pypi.org/project/isodatetime/)\n\nPython ISO 8601 full-specification parser and data model/manipulation utilities. \nIntended to be used in a similar way to Python's datetime module.\n\n## Installation\n\nInstall from PyPI:\n\n```console\n$ pip install isodatetime\n```\n\nOr build yourself:\n\n```console\n$ git clone https://github.com/metomi/isodatetime.git isodatetime\n$ cd isodatetime\n$ python setup.py install\n```\n\n## Usage\n\nPython API:\n\n\n```ruby\n>>> import isodatetime.parsers as parse\n>>> import isodatetime.dumpers as dump\n\n# Dates and times\n>>> date_time = parse.TimePointParser().parse('2000-01-01T00:00Z')\n>>> date_time.month_of_year\n1\n\n# Durations\n>>> duration = parse.DurationParser().parse('P1YT3H')\n>>> duration.get_days_and_seconds()\n(365.0, 10800.0)\n>>> date_time + duration\n2001-01-01T03:00:00Z\n\n# Recurrences\n>>> recurrence = parse.TimeRecurrenceParser().parse('R/1999/P1Y')\n>>> recurrence.get_next(date_time)\n2001-01-01T00:00:00Z\n\n# Output\n>>> dump.TimePointDumper().strftime(date_time, '%d/%M/%Y %H:%M:%S')\n'01/00/2000 00:00:00'\n\n```\n\nCLI:\n\n```console\n$ isodatetime\n2000-01-01T00:00:00Z\n$ isodatetime 1066\n1066\n$ isodatetime 1066 --offset P1Y\n1067\n$ isodatetime R/2000/P1Y --max 3\n2000-01-01T00:00:00Z\n2001-01-01T00:00:00Z\n2002-01-01T00:00:00Z\n```\n\n## ISO8601\n\nISO8601 is an international standard for writing down date/time information.\n\nIt is the correct, internationally-friendly, computer-sortable way to \nnumerically represent date/time information.\n\nGood reading material:\n * http://www.cl.cam.ac.uk/~mgk25/iso-time.html\n * http://www.tondering.dk/claus/calendar.html\n\nReference material:\n * http://www.iso.org/iso/home/standards/iso8601.htm\n * http://en.wikipedia.org/wiki/ISO_8601\n\n### Dates and times\n\n#### How do I write the year, month-of-year, and day-of-month down?\n\nSyntax | Example \n ---------- | ---------- \n CCYYMMDD | 20151231 \n CCYY-MM-DD | 2015-12-31\n\n#### How about writing down the year, week-of-year, and day-of-week?\n\nSyntax | Example\n ---------- | ----------\n CCYYWwwD | 2015W534\n CCYY-Www-D | 2015-W53-4\n\n#### How about writing down the year and day-of-year?\n\nSyntax | Example\n ---------- | ---------\n CCYYDDD | 2015365\n CCYY-DDD | 2015-365\n\n\n#### How do I write just the year?\nEither:\n`CCYY`\nor\n`+XCCYY`\n\n`+X` stands for a plus or minus sign (`+` or `-`), followed by a fixed,\nagreed number of expanded year digits (`X`). For example, if we agree to have\n2 expanded year digits, we can represent years from -999999 to +999999\n(1000000 BC to 999999 AD). Note that 1 BC is the year 0 in the proleptic\nGregorian calendar used by ISO 8601.\n\nFor example, you can write the year 1995 AD as:\n`1995`\nor\n`+001995` (using 2 expanded year digits).\n\nNote: writing just the year where you mean a proper date implies Day 1 of\nMonth 1 in that year - `1995` implies `1995-01` => `1995-01-01` =>\n`1995-01-01T00` => `1995-01-01T00:00` => `1995-01-01T00:00:00`.\n\n#### How do I write just the year and month-of-year?\nEither:\n`CCYY-MM`\nor\n`+XCCYY-MM` (+ standing in here for a `+` or `-` sign)\n\n(not allowed: `CCYYMM` or `+XCCYYMM`).\n\n#### How do I write dates past the year 9999 and before 0000?\n\nSyntax | Example (2 expanded year digits)\n ------------ | ---------\n +XCCYYMMDD | +0020151231\n +XCCYY-MM-DD | +002015-12-31\n +XCCYYWwwD | +002015W534\n +XCCYY-Www-D | +002015-W53-4\n +XCCYYDDD | +002015365\n +XCCYY-DDD | +002015-365\n\n#### How do I write down time information by itself?\n\nSyntax | Example\n ----------------- | -------\n hhmmss | 083000\n hhmm | 0830\n hh:mm:ss | 17:45:01\n hh:mm | 17:45\n hh | 08\n\n#### How do I write down time information at a date in ISO 8601?\n\nWrite the time after the date, separated with a `T`:\n\nSyntax | Example \n ------------------ | ------------------- \n CCYYMMDDThhmmss | 20151231T063101\n CCYY-MM-DDThh:mm:ss | 2015-12-31T06:31:01\n CCYYWwwDThhmmss | 2015W534T063101\n CCYY-Www-DThh:mm:ss | 2015-W53-4T06:31:01\n CCYYDDDThhmmss | 2015365T063101\n CCYY-DDDThh:mm:ss | 2015-365T06:31:01\n\n#### What about just the hour and minute at a date?\n\nSyntax | Example \n --------------- | ---------------- \n CCYYWwwDThhmm | 2015W534T0631\n CCYY-Www-DThh:mm | 2015-W53-4T06:31\n\n#### What about just the hour at a date?\n\nSyntax | Example \n --------------- | ------------- \n CCYYMMDDThh | 20151231T06\n CCYY-MM-DDThh | 2015-12-31T06\n\n#### What about decimal parts of the hour or minute or second?\n\nUse a comma or period to delimit the decimal part, and don't include any\nsmaller units:\n\nSyntax | Example\n ----------------- | ------------------\n CCYYMMDDThh,ii | 20151231T06,5\n CCYYMMDDThh.ii | 20151231T06.5\n CCYYMMDDThhmm,nn | 20151231T0631,3333\n CCYYMMDDThhmm.nn | 20151231T0631.3333\n CCYYMMDDThhmmss,tt | 20151231T063101,25671\n CCYYMMDDThhmmss.tt | 20151231T063101.25671\n\n\n#### How do I specify a time zone?\n\nIf the time zone is UTC, use \"Z\" - otherwise, use a numeric representation\nof the hours and minutes difference from UTC.\n\nNote that this difference is (TIMEZONE - UTC) - so longitudes east of 0 tend\nto have positive differences, and west of 0 usually have negative differences.\n\nSyntax | Example\n ------------------------- | -------------------------\n CCYYMMDDThhmmssZ | 20151231T063101Z\n CCYY-MM-DDThh:mm:ssZ | 2015-12-31T06:31:01Z\n CCYYMMDDThhmmss-hh | 20151231T013101-05\n CCYY-MM-DDThh:mm:ss-hh | 2015-12-31T01:31:01-05\n CCYYMMDDThhmmss+hh | 20151231T083101+02\n CCYY-MM-DDThh:mm:ss+hh | 2015-12-31T08:31:01+02\n CCYYMMDDThhmmss-hhmm | 20151230T203101-1000\n CCYY-MM-DDThh:mm:ss-hh:mm | 2015-12-30T20:31:01-10:00\n CCYYMMDDThhmmss+hhmm | 20151231T193101+1300\n CCYY-MM-DDThh:mm:ss+hh:mm | 2015-12-31T19:31:01+13:00\n\n\n### Durations\n\n#### How do I write down a certain period of time in X units?\n\nA \"P\" followed by the number of units (optionally including a decimal part)\nfollowed by a designator to mark the units:\n\nUnit type | Unit designator\n -------- | ---------------\n years | Y\n months | M\n weeks | W\n days | D\n hours | H\n minutes | M\n seconds | S\n\nIf the unit is one of hours, minutes, or seconds, you need a leading \"T\"\nto delimit time from date:\n\nSyntax | Example | Meaning\n -------- | -------- | ------------------------\n PnY | P2Y | 2 years\n Pn,oY | P5,5Y | 5 and a half years\n Pn.oY | P5.5Y | 5 and a half years\n PTnM | PT7M | 7 minutes (note the 'T')\n PnM | P10M | 10 months\n PnDTnH | P5DT6H | 5 days and 6 hours\n PnW | P2W | 2 weeks\n\nCombining any other unit with weeks is not allowed.\n\nA supplementary format (which has to be agreed in advance) is to specify a\ndate-time-like duration (`PCCYY-MM-DDThh:mm:ss`) where the numbers given for\nyears, months, days, hours, minutes, and seconds are used literally\n(`P1995-00-00T00:10:00` = `P1995YT10M`).\n\n### Recurring date-time series\n\n#### 1 - Recur with a duration given by the difference between a start date\nand a subsequent date, starting at the start date\n\nExample Syntax | Example | Meaning\n ----------------------- | ----------------------- | ------------------------------------------------------------------\nR/CCYY/CCYY | R/2010/2014 | Repeat every 4 years, starting at 2010-01-01.\nR/CCYY-MM/CCYY-DDD | R/2010-01/2012-045 | Repeat every 2 years and 44 days, starting at 2010-01-01\nR5/CCYY-Www-D/CCYY-Www-D | R/2015-W05-2/2015-W07-3 | Repeat every 2 weeks and 1 day, five times, starting at 2015-W05-2\n\n#### 2 - Recur with a given duration, starting at a context date-time\n\n(You have to supply the context somewhere else)\n\nExample Syntax | Example | Meaning\n -------------------- | ---------------- | ------------------------------------------------------------------------------\nR/PnMnDTnM | R/P10M3DT45M | Repeat every 10 months, 3 days, and 45 minutes from a context start date-time.\nRn/PnY | R2/P4Y | Repeat every 4 years, for a total of 2 times, from a context start date-time.\n\n#### 3 - Recur with a given duration starting at a particular date-time\n\nExample Syntax | Example | Meaning\n ------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------\nR/CCYYMMDDThhZ/PTnH | R/20201231T00Z/PT12H | Repeat every 12 hours starting at 2020-12-31T00Z\nR/CCYY-Www-D/PnW | R/2012-W02-1/P1W | Repeat weekly starting at Monday in the second ISO week of 2012\nR/CCYYDDDThhmm/PnD | R/1996291T0630+0100/P2D | Repeat every 2 days starting on the 291st day of 1996 at 06:30, UTC + 1\nRn/CCYY-MM-DDThh:mm/PTnH | R2/19900201T06Z/PT12H | Repeat every 12 hours, for a total of 2 repetitions, starting at 1990-02-01T06Z\nRn/CCYY-Www-D/PnW | R5/2012-W02-1/P1W | Repeat weekly, for a total of 5 repetitions, starting at Monday in the second ISO week of 2012\nRn/CCYYDDDThhmm/PnD | R1/1996291T0630+0100/P2D | Repeat once at the 291st day of 1996 at 06:30, UTC + 1\n\n#### 4 - Recur with a given duration counting back from a particular date-time\n\nExample Syntax | Example | Meaning\n ------------------------- | ------------------------ | ---------------------------------------------------------------\nR/PTnH/CCYY-MM-DDThhZ | R/PT1H/2012-01-02T00Z | Repeat hourly counting back from 2012-01-02T00Z\nR/PnY/CCYY | R/P3Y/2000 | Repeat every 3 years counting back from 2000-01-01.\nR/PTnS/+XCCYYDDDThhmm | R/PT5s/-002500012T1800 | Repeat every 5 seconds counting back from the 12th day in 2501 BC at 18:00 (using 2 expanded year digits).\nRn/PnYTnM/CCYY-MM-DDThhZ | R5/P1YT5M/2012-01-02T00Z | Repeat every year and 5 minutes counting back from 2012-01-02T00Z\nRn/PnM/CCYY-MM | R4/P1M/2000-05 | Repeat monthly, four times, counting back from 2000-05-01.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/metomi/isodatetime", "keywords": "isodatetime datetime iso8601 date time parser", "license": "LGPLv3", "maintainer": "", "maintainer_email": "", "name": "isodatetime", "package_url": "https://pypi.org/project/isodatetime/", "platform": "any", "project_url": "https://pypi.org/project/isodatetime/", "project_urls": { "Homepage": "https://github.com/metomi/isodatetime" }, "release_url": "https://pypi.org/project/isodatetime/1!2.0.0/", "requires_dist": null, "requires_python": ">=3.4, <3.8", "summary": "Python ISO 8601 date time parser and data model/manipulation utilities", "version": "1!2.0.0" }, "last_serial": 5854825, "releases": { "1!2.0.0": [ { "comment_text": "", "digests": { "md5": "b6f1cc1153b00918c35b2a3efdb55a01", "sha256": "202281e77d9085d9510dc9b7de623b0a31810529cbf1430c910b22dfe0c72906" }, "downloads": -1, "filename": "isodatetime-1!2.0.0-py3.7.egg", "has_sig": false, "md5_digest": "b6f1cc1153b00918c35b2a3efdb55a01", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": ">=3.4, <3.8", "size": 89904, "upload_time": "2019-07-16T08:47:03", "url": "https://files.pythonhosted.org/packages/3b/0f/13fbfff644f98daf85170cb08750b35dee31f14c9fa0e6ca90537d5f30ea/isodatetime-1!2.0.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "5efd196f8121d7429091bc01765da1ef", "sha256": "4344274fe3116835fd49248a1dd4e8d2ace7688f53a9e956d39912504d00e6aa" }, "downloads": -1, "filename": "isodatetime-1!2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5efd196f8121d7429091bc01765da1ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4, <3.8", "size": 49413, "upload_time": "2019-01-23T14:37:56", "url": "https://files.pythonhosted.org/packages/35/8d/dc099a6d651be73399b7cba7f74692e0b4a0514efaa2c94bb95ab5bd2901/isodatetime-1!2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d082a888b14191b7f2068b277af7b992", "sha256": "a856d0be7a78328c99c906df88a4ba572a91c26abfd5c5b07d3705b985a8259d" }, "downloads": -1, "filename": "isodatetime-1!2.0.0.tar.gz", "has_sig": false, "md5_digest": "d082a888b14191b7f2068b277af7b992", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4, <3.8", "size": 43009, "upload_time": "2019-01-23T14:37:58", "url": "https://files.pythonhosted.org/packages/cd/66/c447f0a20037f4b98f59502a4747f09492ee3b431a50ce61846a64921ebb/isodatetime-1!2.0.0.tar.gz" } ], "2018.11.0": [ { "comment_text": "", "digests": { "md5": "d4201ed7b0ff42f2984dcd1083ac5684", "sha256": "069e44823cab73805e8cfd5cd67dad120e35e29d3e9f83e9c14aa64b88c174fe" }, "downloads": -1, "filename": "isodatetime-2018.11.0-py2-none-any.whl", "has_sig": false, "md5_digest": "d4201ed7b0ff42f2984dcd1083ac5684", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": ">=2.6, <3.0", "size": 47735, "upload_time": "2018-11-06T19:46:43", "url": "https://files.pythonhosted.org/packages/23/56/3eba9a92074137eb94742eecc88af0029be67aff8aa2c9a4fa01464d8b4f/isodatetime-2018.11.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a4552cd0eea01d17c4d31288b398a684", "sha256": "481b99268e8198b747b8f4477d449de2a2ef1ef065873014479bfad9e55dccd1" }, "downloads": -1, "filename": "isodatetime-2018.11.0.tar.gz", "has_sig": false, "md5_digest": "a4552cd0eea01d17c4d31288b398a684", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.6, <3.0", "size": 42131, "upload_time": "2018-11-06T19:46:46", "url": "https://files.pythonhosted.org/packages/fb/35/826652c70dc62a180ffff424e8e2f2a9118e20711fe5092afe66232f5b0c/isodatetime-2018.11.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b6f1cc1153b00918c35b2a3efdb55a01", "sha256": "202281e77d9085d9510dc9b7de623b0a31810529cbf1430c910b22dfe0c72906" }, "downloads": -1, "filename": "isodatetime-1!2.0.0-py3.7.egg", "has_sig": false, "md5_digest": "b6f1cc1153b00918c35b2a3efdb55a01", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": ">=3.4, <3.8", "size": 89904, "upload_time": "2019-07-16T08:47:03", "url": "https://files.pythonhosted.org/packages/3b/0f/13fbfff644f98daf85170cb08750b35dee31f14c9fa0e6ca90537d5f30ea/isodatetime-1!2.0.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "5efd196f8121d7429091bc01765da1ef", "sha256": "4344274fe3116835fd49248a1dd4e8d2ace7688f53a9e956d39912504d00e6aa" }, "downloads": -1, "filename": "isodatetime-1!2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5efd196f8121d7429091bc01765da1ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.4, <3.8", "size": 49413, "upload_time": "2019-01-23T14:37:56", "url": "https://files.pythonhosted.org/packages/35/8d/dc099a6d651be73399b7cba7f74692e0b4a0514efaa2c94bb95ab5bd2901/isodatetime-1!2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d082a888b14191b7f2068b277af7b992", "sha256": "a856d0be7a78328c99c906df88a4ba572a91c26abfd5c5b07d3705b985a8259d" }, "downloads": -1, "filename": "isodatetime-1!2.0.0.tar.gz", "has_sig": false, "md5_digest": "d082a888b14191b7f2068b277af7b992", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.4, <3.8", "size": 43009, "upload_time": "2019-01-23T14:37:58", "url": "https://files.pythonhosted.org/packages/cd/66/c447f0a20037f4b98f59502a4747f09492ee3b431a50ce61846a64921ebb/isodatetime-1!2.0.0.tar.gz" } ] }