metomi-isodatetime


Namemetomi-isodatetime JSON
Version 1!3.1.0 PyPI version JSON
download
home_pagehttps://github.com/metomi/isodatetime
SummaryPython ISO 8601 date time parser and data model/manipulation utilities
upload_time2023-10-05 12:14:39
maintainer
docs_urlNone
authorMet Office
requires_python>=3.7
licenseLGPLv3
keywords isodatetime datetime iso8601 date time parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            isodatetime
===========

[![Test](https://github.com/metomi/isodatetime/workflows/Test/badge.svg?event=push)](https://github.com/metomi/isodatetime/actions?query=workflow%3ATest)
[![codecov](https://codecov.io/gh/metomi/isodatetime/branch/master/graph/badge.svg)](https://codecov.io/gh/metomi/isodatetime)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.597555.svg)](https://doi.org/10.5281/zenodo.597555)
[![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)
[![PYPI Badge](https://img.shields.io/pypi/v/metomi-isodatetime)](https://pypi.org/project/metomi-isodatetime/)

Python [ISO8601 (2004)](https://www.iso.org/standard/40874.html)
full-specification parser and data model/manipulation utilities.
Intended to be used in a similar way to Python's datetime module.

## Installation

Install from PyPI:

```console
$ pip install metomi-isodatetime
```

Or build yourself:

```console
$ git clone https://github.com/metomi/isodatetime.git isodatetime
$ cd isodatetime
$ python setup.py install
```

## Usage

Python API:

<!-- GitHub Python syntax highlighting has issues with datetimes, Ruby works
     reasonably well as a stand-in. -->
```ruby
>>> import metomi.isodatetime.parsers as parse
>>> import metomi.isodatetime.dumpers as dump

# Dates and times
>>> date_time = parse.TimePointParser().parse('2000-01-01T00:00Z')
>>> date_time.month_of_year
1

# Durations
>>> duration = parse.DurationParser().parse('P1YT3H')
>>> duration.get_days_and_seconds()
(365.0, 10800.0)
>>> date_time + duration
<metomi.isodatetime.data.TimePoint: 2001-01-01T03:00:00Z>

# Recurrences
>>> recurrence = parse.TimeRecurrenceParser().parse('R/1999/P1Y')
>>> recurrence.get_next(date_time)
<metomi.isodatetime.data.TimePoint: 2001-01-01T00:00:00Z>

# Output
>>> dump.TimePointDumper().strftime(date_time, '%d/%M/%Y %H:%M:%S')
'01/00/2000 00:00:00'

```

CLI:

```console
$ isodatetime
2000-01-01T00:00:00Z
$ isodatetime 1066
1066
$ isodatetime 1066 --offset P1Y
1067
$ isodatetime R/2000/P1Y --max 3
2000-01-01T00:00:00Z
2001-01-01T00:00:00Z
2002-01-01T00:00:00Z
```

## Copyright and Terms of Use

Copyright (C) 2013-<span actions:bind='current-year'>2023</span> British Crown
(Met Office) & Contributors.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program.  If not, see [GNU licenses](http://www.gnu.org/licenses/).

## ISO 8601

[ISO 8601 (2004)](https://www.iso.org/standard/40874.html)
is an international standard for writing down date/time information.

It is the correct, internationally-friendly, computer-sortable way to
numerically represent date/time information.

Good reading material:
 * http://www.cl.cam.ac.uk/~mgk25/iso-time.html
 * http://www.tondering.dk/claus/calendar.html

Reference material:
 * http://www.iso.org/iso/home/standards/iso8601.htm
 * http://en.wikipedia.org/wiki/ISO_8601

### Dates and times

#### How do I write the year, month-of-year, and day-of-month down?

Syntax      | Example
 ---------- | ----------
 CCYYMMDD    | 20151231
 CCYY-MM-DD  | 2015-12-31

#### How about writing down the year, week-of-year, and day-of-week?

Syntax      | Example
 ---------- | ----------
 CCYYWwwD    | 2015W534
 CCYY-Www-D  | 2015-W53-4

#### How about writing down the year and day-of-year?

Syntax      | Example
 ---------- | ---------
 CCYYDDD     | 2015365
 CCYY-DDD    | 2015-365


#### How do I write just the year?
Either:
`CCYY`
or
`+XCCYY`

`+X` stands for a plus or minus sign (`+` or `-`), followed by a fixed,
agreed number of expanded year digits (`X`). For example, if we agree to have
2 expanded year digits, we can represent years from -999999 to +999999
(1000000 BC to 999999 AD). Note that 1 BC is the year 0 in the proleptic
Gregorian calendar used by ISO 8601.

For example, you can write the year 1995 AD as:
`1995`
or
`+001995` (using 2 expanded year digits).

Note: writing just the year where you mean a proper date implies Day 1 of
Month 1 in that year - `1995` implies `1995-01` => `1995-01-01` =>
`1995-01-01T00` => `1995-01-01T00:00` => `1995-01-01T00:00:00`.

#### How do I write just the year and month-of-year?
Either:
`CCYY-MM`
or
`+XCCYY-MM` (+ standing in here for a `+` or `-` sign)

(not allowed: `CCYYMM` or `+XCCYYMM`).

#### How do I write dates past the year 9999 and before 0000?

Syntax        | Example (2 expanded year digits)
 ------------ | ---------
 +XCCYYMMDD   | +0020151231
 +XCCYY-MM-DD | +002015-12-31
 +XCCYYWwwD   | +002015W534
 +XCCYY-Www-D | +002015-W53-4
 +XCCYYDDD    | +002015365
 +XCCYY-DDD   | +002015-365

#### How do I write down time information by itself?

Syntax             | Example
 ----------------- | -------
 hhmmss             | 083000
 hhmm               | 0830
 hh:mm:ss           | 17:45:01
 hh:mm              | 17:45
 hh                 | 08

#### How do I write down time information at a date in ISO 8601?

Write the time after the date, separated with a `T`:

Syntax              | Example
 ------------------ | -------------------
 CCYYMMDDThhmmss     | 20151231T063101
 CCYY-MM-DDThh:mm:ss | 2015-12-31T06:31:01
 CCYYWwwDThhmmss     | 2015W534T063101
 CCYY-Www-DThh:mm:ss | 2015-W53-4T06:31:01
 CCYYDDDThhmmss      | 2015365T063101
 CCYY-DDDThh:mm:ss   | 2015-365T06:31:01

#### What about just the hour and minute at a date?

Syntax           | Example
 --------------- | ----------------
 CCYYWwwDThhmm    | 2015W534T0631
 CCYY-Www-DThh:mm | 2015-W53-4T06:31

#### What about just the hour at a date?

Syntax           | Example
 --------------- | -------------
 CCYYMMDDThh      | 20151231T06
 CCYY-MM-DDThh    | 2015-12-31T06

#### What about decimal parts of the hour or minute or second?

Use a comma or period to delimit the decimal part, and don't include any
smaller units:

Syntax             | Example
 ----------------- | ------------------
 CCYYMMDDThh,ii     | 20151231T06,5
 CCYYMMDDThh.ii     | 20151231T06.5
 CCYYMMDDThhmm,nn   | 20151231T0631,3333
 CCYYMMDDThhmm.nn   | 20151231T0631.3333
 CCYYMMDDThhmmss,tt | 20151231T063101,25671
 CCYYMMDDThhmmss.tt | 20151231T063101.25671


#### How do I specify a time zone?

If the time zone is UTC, use "Z" - otherwise, use a numeric representation
of the hours and minutes difference from UTC.

Note that this difference is (TIMEZONE - UTC) - so longitudes east of 0 tend
to have positive differences, and west of 0 usually have negative differences.

Syntax                     | Example
 ------------------------- | -------------------------
 CCYYMMDDThhmmssZ           | 20151231T063101Z
 CCYY-MM-DDThh:mm:ssZ       | 2015-12-31T06:31:01Z
 CCYYMMDDThhmmss-hh         | 20151231T013101-05
 CCYY-MM-DDThh:mm:ss-hh     | 2015-12-31T01:31:01-05
 CCYYMMDDThhmmss+hh         | 20151231T083101+02
 CCYY-MM-DDThh:mm:ss+hh     | 2015-12-31T08:31:01+02
 CCYYMMDDThhmmss-hhmm       | 20151230T203101-1000
 CCYY-MM-DDThh:mm:ss-hh:mm  | 2015-12-30T20:31:01-10:00
 CCYYMMDDThhmmss+hhmm       | 20151231T193101+1300
 CCYY-MM-DDThh:mm:ss+hh:mm  | 2015-12-31T19:31:01+13:00


### Durations

#### How do I write down a certain period of time in X units?

A "P" followed by the number of units (optionally including a decimal part)
followed by a designator to mark the units:

Unit type | Unit designator
 -------- | ---------------
 years    | Y
 months   | M
 weeks    | W
 days     | D
 hours    | H
 minutes  | M
 seconds  | S

If the unit is one of hours, minutes, or seconds, you need a leading "T"
to delimit time from date:

Syntax    | Example  | Meaning
 -------- | -------- | ------------------------
 PnY      |  P2Y     | 2 years
 PTnM     |  PT7M    | 7 minutes (note the 'T')
 PnM      |  P10M    | 10 months
 PnDTnH   |  P5DT6H  | 5 days and 6 hours
 PTn,oH   |  PT5,5H  | 5 and a half hours
 PTn.oH   |  PT5.5H  | 5 and a half hours
 PnW      |  P2W     | 2 weeks

Combining any other unit with weeks is not allowed. Decimals may only be used
for hours, minutes and seconds.

Note that years and months are "nominal" durations, whose exact length of time
depends on their position in the calendar. E.g., a duration of 1 calendar year
starts on a particular day of a particular month and ends on the same day of
the same month in the following calendar year, and may be different to 365 days
in the Gregorian calendar due to leap years.

Conversely, weeks, days, hours, minutes and seconds are exact units, so
`P1W == P7D`, `P1D == PT24H` and `PT1H == PT60M` etc. are always true.
(Although ISO 8601 specifies that weeks and days are nominal durations, there
is no case where they are not exact in our implementation.)
<!-- ...because TimePoints always have time zones assigned to them (apart
from truncated TimePoints, but you can't add Durations to truncated
TimePoints). Local time zones don't actually exist in our implementation. -->

A supplementary format (which has to be agreed in advance) is to specify a
date-time-like duration (`PCCYY-MM-DDThh:mm:ss`) where the numbers given for
years, months, days, hours, minutes, and seconds are used literally
(`P1995-00-00T00:10:00` = `P1995YT10M`).

### Recurring date-time series

#### 1. Recur with a duration given by the difference between a start date and a subsequent date

Example Syntax                 | Example                          | Meaning
 ----------------------------- | -------------------------------- | ------------------------------------------------------------------
R/CCYY/CCYY                    | R/2010/2014                      | Repeat every 1461 days (≈ 4 years\*), starting at 2010-01-01
R/CCYY-MM/CCYY-DDD             | R/2010-01/2012-045               | Repeat every 774 days (≈ 2 years and 44 days\*), starting at 2010-01-01
Rn/CCYY-Www-D/CCYY-Www-D       | R5/2015-W05-2/2015-W07-3         | Repeat every 15 days (= 2 weeks and 1 day), five times, starting at 2015-W05-2
Rn/CCYY-MM-DDThh/CCYY-MM-DDThh | R1/1925-02-11T00Z/2027-06-01T00Z | Repeat once at 1925-02-11T00Z (note the end date-time is ignored)

\*See the previous section as to why only an approximate equivalent number of
years are given.

#### 2. Recur with a specified duration, starting at a context date-time

(You have to supply the context somewhere else)

Example Syntax        | Example          | Meaning
 -------------------- | ---------------- | ------------------------------------------------------------------------------
R/PnMnDTnM            | R/P10M3DT45M     | Repeat every 10 months, 3 days, and 45 minutes from a context start date-time.
Rn/PnY                | R2/P4Y           | Repeat every 4 years, for a total of 2 times, from a context start date-time.

#### 3. Recur with a specified duration starting at a particular date-time

Example Syntax             | Example                  | Meaning
 ------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------
R/CCYYMMDDThhZ/PTnH        | R/20201231T00Z/PT12H     | Repeat every 12 hours starting at 2020-12-31T00Z
R/CCYY-Www-D/PnW           | R/2012-W02-1/P1W         | Repeat weekly starting at Monday in the second ISO week of 2012
R/CCYYDDDThhmm/PnD         | R/1996291T0630+0100/P2D  | Repeat every 2 days starting on the 291st day of 1996 at 06:30, UTC + 1
Rn/CCYY-MM-DDThh:mm/PTnH   | R2/19900201T06Z/PT12H    | Repeat every 12 hours, for a total of 2 repetitions, starting at 1990-02-01T06Z
Rn/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
Rn/CCYYDDDThhmm/PnD        | R1/1996291T0630Z/P2D     | Repeat once on the 291st day of 1996 at 06:30 (note the duration is ignored)

#### 4. Recur with a specified duration ending at a particular date-time

The starting date-time of the recurrence is calculated from the specified
duration.

Example Syntax             | Example                  | Meaning
 ------------------------- | ------------------------ | ---------------------------------------------------------------
R/PTnH/CCYY-MM-DDThhZ      | R/PT1H/2012-01-02T00Z    | Repeat hourly, ending at 2012-01-02T00Z (therefore repeats on the hour)
R/PnY/CCYY                 | R/P3Y/2000               | Repeat every 3 years, ending at 2000-01-01 (therefore repeats at 00:00 January 1st)
R/PTnS/+XCCYYDDDThhmm      | R/PT5s/-002500012T1800   | Repeat every 5 seconds, ending on the 12th day in 2501 BC at 18:00 (using 2 expanded year digits)
Rn/PnYTnM/CCYY-MM-DDThhZ   | R5/P1YT5M/2012-01-02T00Z | Repeat every year and 5 minutes, five times, ending at 2012-01-02T00Z
Rn/PnM/CCYY-MM             | R4/P1M/2000-05           | Repeat monthly, four times, ending at 2000-05-01 (therefore repeats on the first of the month)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/metomi/isodatetime",
    "name": "metomi-isodatetime",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "isodatetime datetime iso8601 date time parser",
    "author": "Met Office",
    "author_email": "metomi@metoffice.gov.uk",
    "download_url": "https://files.pythonhosted.org/packages/00/cc/e910e3e8616807dfb9a526e2887623398fee67c987a2112aee103bd120f5/metomi-isodatetime-1!3.1.0.tar.gz",
    "platform": "any",
    "description": "isodatetime\n===========\n\n[![Test](https://github.com/metomi/isodatetime/workflows/Test/badge.svg?event=push)](https://github.com/metomi/isodatetime/actions?query=workflow%3ATest)\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&amp;utm_medium=referral&amp;utm_content=metomi/isodatetime&amp;utm_campaign=Badge_Grade)\n[![PYPI Badge](https://img.shields.io/pypi/v/metomi-isodatetime)](https://pypi.org/project/metomi-isodatetime/)\n\nPython [ISO8601 (2004)](https://www.iso.org/standard/40874.html)\nfull-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 metomi-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<!-- GitHub Python syntax highlighting has issues with datetimes, Ruby works\n     reasonably well as a stand-in. -->\n```ruby\n>>> import metomi.isodatetime.parsers as parse\n>>> import metomi.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\n<metomi.isodatetime.data.TimePoint: 2001-01-01T03:00:00Z>\n\n# Recurrences\n>>> recurrence = parse.TimeRecurrenceParser().parse('R/1999/P1Y')\n>>> recurrence.get_next(date_time)\n<metomi.isodatetime.data.TimePoint: 2001-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## Copyright and Terms of Use\n\nCopyright (C) 2013-<span actions:bind='current-year'>2023</span> British Crown\n(Met Office) & Contributors.\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU Lesser General Public License as published by the Free\nSoftware Foundation, either version 3 of the License, or (at your option) any\nlater version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE.  See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along\nwith this program.  If not, see [GNU licenses](http://www.gnu.org/licenses/).\n\n## ISO 8601\n\n[ISO 8601 (2004)](https://www.iso.org/standard/40874.html)\nis 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 PTnM     |  PT7M    | 7 minutes (note the 'T')\n PnM      |  P10M    | 10 months\n PnDTnH   |  P5DT6H  | 5 days and 6 hours\n PTn,oH   |  PT5,5H  | 5 and a half hours\n PTn.oH   |  PT5.5H  | 5 and a half hours\n PnW      |  P2W     | 2 weeks\n\nCombining any other unit with weeks is not allowed. Decimals may only be used\nfor hours, minutes and seconds.\n\nNote that years and months are \"nominal\" durations, whose exact length of time\ndepends on their position in the calendar. E.g., a duration of 1 calendar year\nstarts on a particular day of a particular month and ends on the same day of\nthe same month in the following calendar year, and may be different to 365 days\nin the Gregorian calendar due to leap years.\n\nConversely, weeks, days, hours, minutes and seconds are exact units, so\n`P1W == P7D`, `P1D == PT24H` and `PT1H == PT60M` etc. are always true.\n(Although ISO 8601 specifies that weeks and days are nominal durations, there\nis no case where they are not exact in our implementation.)\n<!-- ...because TimePoints always have time zones assigned to them (apart\nfrom truncated TimePoints, but you can't add Durations to truncated\nTimePoints). Local time zones don't actually exist in our implementation. -->\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 and a subsequent date\n\nExample Syntax                 | Example                          | Meaning\n ----------------------------- | -------------------------------- | ------------------------------------------------------------------\nR/CCYY/CCYY                    | R/2010/2014                      | Repeat every 1461 days (\u2248 4 years\\*), starting at 2010-01-01\nR/CCYY-MM/CCYY-DDD             | R/2010-01/2012-045               | Repeat every 774 days (\u2248 2 years and 44 days\\*), starting at 2010-01-01\nRn/CCYY-Www-D/CCYY-Www-D       | R5/2015-W05-2/2015-W07-3         | Repeat every 15 days (= 2 weeks and 1 day), five times, starting at 2015-W05-2\nRn/CCYY-MM-DDThh/CCYY-MM-DDThh | R1/1925-02-11T00Z/2027-06-01T00Z | Repeat once at 1925-02-11T00Z (note the end date-time is ignored)\n\n\\*See the previous section as to why only an approximate equivalent number of\nyears are given.\n\n#### 2. Recur with a specified 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 specified 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/1996291T0630Z/P2D     | Repeat once on the 291st day of 1996 at 06:30 (note the duration is ignored)\n\n#### 4. Recur with a specified duration ending at a particular date-time\n\nThe starting date-time of the recurrence is calculated from the specified\nduration.\n\nExample Syntax             | Example                  | Meaning\n ------------------------- | ------------------------ | ---------------------------------------------------------------\nR/PTnH/CCYY-MM-DDThhZ      | R/PT1H/2012-01-02T00Z    | Repeat hourly, ending at 2012-01-02T00Z (therefore repeats on the hour)\nR/PnY/CCYY                 | R/P3Y/2000               | Repeat every 3 years, ending at 2000-01-01 (therefore repeats at 00:00 January 1st)\nR/PTnS/+XCCYYDDDThhmm      | R/PT5s/-002500012T1800   | Repeat every 5 seconds, ending on 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, five times, ending at 2012-01-02T00Z\nRn/PnM/CCYY-MM             | R4/P1M/2000-05           | Repeat monthly, four times, ending at 2000-05-01 (therefore repeats on the first of the month)\n",
    "bugtrack_url": null,
    "license": "LGPLv3",
    "summary": "Python ISO 8601 date time parser and data model/manipulation utilities",
    "version": "1!3.1.0",
    "project_urls": {
        "Homepage": "https://github.com/metomi/isodatetime"
    },
    "split_keywords": [
        "isodatetime",
        "datetime",
        "iso8601",
        "date",
        "time",
        "parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b5f8446ce923b5aa995e5fbd75af4f00cc6666fd16883add8c9644b4f89ef04",
                "md5": "22a7e32fa0011e6352d7f770e7556303",
                "sha256": "837880717817d0325703b9b3ce94093fc92fc7ac18cd14f9fe389f2d21266407"
            },
            "downloads": -1,
            "filename": "metomi_isodatetime-1!3.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "22a7e32fa0011e6352d7f770e7556303",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 81676,
            "upload_time": "2023-10-05T12:14:37",
            "upload_time_iso_8601": "2023-10-05T12:14:37.634145Z",
            "url": "https://files.pythonhosted.org/packages/8b/5f/8446ce923b5aa995e5fbd75af4f00cc6666fd16883add8c9644b4f89ef04/metomi_isodatetime-1!3.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00cce910e3e8616807dfb9a526e2887623398fee67c987a2112aee103bd120f5",
                "md5": "1a97cde9f5c27e76cec4290ad2db88a5",
                "sha256": "2ec15eb9c323d5debd0678f33af99bc9a91aa0b534ee5f65f3487aed518ebf2d"
            },
            "downloads": -1,
            "filename": "metomi-isodatetime-1!3.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1a97cde9f5c27e76cec4290ad2db88a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 74350,
            "upload_time": "2023-10-05T12:14:39",
            "upload_time_iso_8601": "2023-10-05T12:14:39.936161Z",
            "url": "https://files.pythonhosted.org/packages/00/cc/e910e3e8616807dfb9a526e2887623398fee67c987a2112aee103bd120f5/metomi-isodatetime-1!3.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-05 12:14:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "metomi",
    "github_project": "isodatetime",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "metomi-isodatetime"
}
        
Elapsed time: 0.12741s