Determine Event Recurrence Pattern for a set of dates

后端 未结 8 512
梦毁少年i
梦毁少年i 2021-01-31 19:32

I am looking for a pattern, algorithm, or library that will take a set of dates and return a description of the recurrence if one exits, i.e. the set [11-01-2010, 11-08-2010, 11

8条回答
  •  执念已碎
    2021-01-31 19:49

    If your purpose is to generate human-readable descriptions of the pattern, as in your "Every Monday in November", then you probably want to start by enumerating the possible descriptions. Descriptions can be broken down into frequency and bounds, for example,

    Frequency:

    • Every day ...
    • Every other/third/fourth day ...
    • Weekdays/weekends ...
    • Every Monday ...
    • Alternate Mondays ...
    • The first/second/last Monday ...
    • ...

    Bounds:

    • ... in January
    • ... between 25 March and 25 October
    • ...

    There won't be all that many of each, and you can check for them one by one.

提交回复
热议问题