If a user has several holidays one after another, we want to show the farthest end date.
For example, let's say today is Monday, and I am sick, and I also have days off from Tuesday to Friday. Then we want to show Friday as an end date of my time off.
Or let's say I have a vacation from Monday to Friday and at the same time there is a public holiday in my country on Monday. We want to show Friday as the end of my time off in this case.
Before, the calendar plugin was setting this custom holiday flair in many places in Discourse. Starting from this PR, the calendar plugin will be setting user status in core instead.
Note that from now we start to show holiday's end date. If a user has several holiday events simultaneously (this can happen easily, for example, if a user is on vacation and today is a public holiday in their country), the date will be taken from the longest event.
Note also that there is an edge case that's not handled in this PR - if a user has several holidays one after another (let's say they are sick this week and has a vacation on the next week), it would be nice to show as the end date of the holiday the ending date of the second holiday. For now, the plugin uses the end date of the current holiday in such cases, but I'll improve it in one of the next PRs.
Also, in this PR, I directly use methods of the user model from Core. We definitely need API calls instead. This fix is also coming soon.