ISO 8601 重复间隔

发布于 2024-12-03 17:00:44 字数 584 浏览 4 评论 0原文

维基百科提供了 ISO 8601 示例 重复间隔

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

这就是这个意思:

  • R5 表示间隔斜线重复 5 次后。
  • 2008-03-01T13:00:00Z 表示间隔从此给定日期时间开始。
  • P1Y2M10DT2H30M表示间隔持续时间
    • 1 年
    • 2个月
    • 10 天
    • 2小时
    • 30 分钟

我的问题是我不知道这里到底重复了什么。是否重复 间隔结束后立即发生吗?我可以指定每周一 13:00 到 14:00 发生活动吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷默言语 2024-12-10 17:00:44

标准本身并没有明确说明,但这里唯一明显的解释是间隔连续重复。所以这个重复间隔:

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

将相当于这些非重复间隔:(

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

注:我的阅读是重复次数确实包括第一次出现)

没有办法表示“每周一从 13:00 到 14:00” ISO 8601 内部,但对于 iCalendar 格式的 VEVENT 来说这是很自然的。 (如果您可以完全在 ISO 8601 范围内做到这一点,那么这将引起一系列进一步的功能请求)

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)

终难愈 2024-12-10 17:00:44

是的,ISO8601 确实定义了规则重复间隔(或者像“月”一样规则可以作为单位之一)。

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

应该生成这些时间:

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

它不像 RFC5545 (iCalendar) 那样定义“开始时间”和“结束时间”,甚至不像 RRULE 或 crontab 那样定义不规则重复。

您应该能够使用 ISO 周日期作为起点指定每周重复,但您需要为“开始”和“结束”时间单独重复:

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

第一个间隔用于开始时间:星期一 13:00 (从 2021 年开始),第二个是结束时间:每周一 14:00(从 2021 年开始)。

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).

分开我的手 2024-12-10 17:00:44

我可能是个白痴(Long Covid Brain),但 ISO-8601 的明显扩展不是第二个持续时间部分吗?在没有第二持续时间的情况下,重复是背靠背的,在存在第二持续时间的情况下,实际重复的是每个周期开始时的较小持续时间事件。例如,

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

  • 从 2021 年第一周开始每周一下午 1 点无限期重复一小时长时段。

编辑:也许你甚至可以嵌套它们...

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

  • 周一至周五,上午 9 点至下午 5 点,每天 星期?好的,我去拿我的外套

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文