rocmax
V2EX  ›  问与答

一个 rrule 的规则问题

  •  
  •   rocmax · Feb 20, 2024 via Android · 943 views
    This topic created in 816 days ago, the information mentioned may be changed or developed.

    今天( 2024/2/20 )是本月的第 4 周周二还是第 3 周周二? 发现 rrule 里定义为+3TU 才会命中今天 而 date-fns 的 getWeekOfMonth 返回的是 4 ,导致生成的 rrule 命中 27 日。 rrule 和 date-fns 都已设置为周一为一周的开始

    有没有什么设定可以统一这两个数,或者说第几周的周几有没有一个明确定义?关键是第一周大于几天算是一周

    rocmax
        1
    rocmax  
    OP
       Feb 20, 2024
    稍微测试了一下,明白了问题所在。

    rrule 的第 n 个周二的意思是周二在这个月中出现的次数,如果这月 1 号是周三的话第 3 个周二其实是第 4 周的周二。

    getWeekOfMonth 返回的是第 n 周的周二
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3121 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:18 · PVG 21:18 · LAX 06:18 · JFK 09:18
    ♥ Do have faith in what you're doing.