17

Wikipedia gives an example of an ISO 8601 example of a repeating interval:

R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M

This is what this means:

  • R5 means that the interval after the slash is repeated 5 times.
  • 2008-03-01T13:00:00Z means that the interval begins at this given datetime.
  • P1Y2M10DT2H30M means that the interval lasts for
    • 1 year
    • 2 months
    • 10 days
    • 2 hours
    • 30 minutes

My problem is that I do not know exactly what is being repeated here. Does the repetition occur immediately after the interval ends? Can I specify that every Monday something happens from 13:00 to 14:00?

Ryan Gates
  • 4,501
  • 6
  • 50
  • 90
kzh
  • 19,810
  • 13
  • 73
  • 97
  • For "intervals" without a specific start or end date, I've created a format based on ISO 8601. It is used in these [JavaScript](https://github.com/smhg/date-frequency-js) and [PHP](https://github.com/smhg/date-frequency-php) libraries. "every Monday at 13:00:00" in your example is written as "F1D/WT13H0M0S". The 1h interval (duration) can be stored independently. – smhg Aug 25 '14 at 17:18
  • @smhg Do you have a document that outlines your extensions? If so, I would really like to read it, if not, let's make one! – kzh Aug 25 '14 at 20:08
  • 1
    I've been reading into RFC 5545's [RRULE](http://tools.ietf.org/html/rfc5545#section-3.3.10) (of iCalendar) based on Mu Mind's answer. My format depends on external filter functions for more advanced operations (e.g. F(odd)W/ET10H0M0S for every day at 10:00:00 in odd weeks). RRULE allows you to specify everything inline but it's not readable by humans (without knowledge of the rfc). In my use-cases it's a trade-off I'm willing to make. So I'll rewrite both libraries using this existing standard. – smhg Aug 26 '14 at 11:30

3 Answers3

10

The standard itself doesn't clarify, but the only obvious interpretation here is that the interval repeats back-to-back. So this recurring interval:

R2/2008-03-01T13:00:00Z/P1Y2M10DT2H30M

Will be equivalent to these non-recurring intervals:

2008-03-01T13:00:00Z/P1Y2M10DT2H30M
2009-05-01T15:30:00Z/P1Y2M10DT2H30M

(Note: my reading is that the number of repetitions does include the first occurrence)

There is no way to represent "every Monday from 13:00 to 14:00" inside of ISO 8601, but it's natural to do for a VEVENT in the iCalendar format. (If you could do that entirely within ISO 8601, then that would give rise to a slew of further feature requests)

Mu Mind
  • 10,935
  • 4
  • 38
  • 69
  • And how would you interpret "R2/P1M/2008-03-01T13:00:00Z" (duration and end date)? Do you think it is the same as "R2/2008-02-01T13:00:00Z/P1M" ? – Melanie Sep 19 '14 at 19:14
  • Nope. It would mean that the repeating ends on that date, but goes on for infinity into the past. – Ole Tange Jun 05 '17 at 07:15
  • 2
    Since the number of `[n]` is specified, I interpret it to mean it doesn't go back infinitely in time. – Noel Yap Feb 27 '18 at 23:11
  • Representing "every Monday from 13:00 to 14:00" is possible since ISO 8601-2-2019 with _Selections_ used in _Recurring time intervals with repeat rules_ (Chapter 13). – felixfbecker May 04 '23 at 22:32
2

Yes, ISO8601 does define a regular repeating interval (or as regular as a "month" can be as one of the units).

R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M

Should generate these times:

2009-05-11T15:30:00Z
2010-07-21T18:00:00Z
2011-10-01T20:30:00Z
2012-12-11T23:00:00Z
2014-02-22T00:30:00Z

It doesn't define a "start time" and "end time" like RFC5545 (iCalendar) does, or even irregular repetition like RRULE or crontab can.

You should be able to specify a weekly repetition using the ISO Week Date as a starting point, but you'll need separate repetitions for "start" and "end" times:

R/2021-W01-1T13:00:00Z/P1W
R/2021-W01-1T14:00:00Z/P1W

The first interval is for the start times: Mondays at 13:00 (starting in 2021), and the second is for the end times: Mondays at 14:00 (starting in 2021).

brianary
  • 8,996
  • 2
  • 35
  • 29
0

I'm probably being an idiot (Long Covid Brain) but isn't the obvious extension to ISO-8601 a second duration part? In the absence of the second duration, the repeats are back to back, in its presence what is actually repeating is a smaller duration event at the start of each period. e.g.

R/2021-W01-1T13:00:00Z/P1W/P1H

  • indefinite weekly repeat of hour long slots every Monday 1pm starting week 1 2021.

EDIT: Maybe you could even nest them ...

R/2021-W01-1T09:00:00Z/P1W/R5/P1D/P8H

  • Mon to Fri, 9am to 5pm, every week? Ok I'll get my coat