How to get the first and the last dates (day and month) of a specified week number (1-53) in a particular year?

后端 未结 2 654
野趣味
野趣味 2021-01-23 06:08

If the week number in a particular year is given, how can I determine the the first and the last dates (day and month) of the week in an easy way by using C/C++? Thank you in ad

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 06:24

    This is heavily affected by local rules for week numbering. There are at least two common rules for what week day is the start of a week, there are three common rules for what week is numbered 1 at the start of the year.

    Avoid having to endlessly tinker with that kind of code and use a library. The ICU library covers this with its Calendar classes. The relevant introduction page is here. Check the notes on the WEEK_OF_YEAR field at the bottom of the page.

提交回复
热议问题