Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeSpan between 2 dates removing weekends and holidays. #21

Closed
matjos opened this issue Sep 22, 2017 · 2 comments
Closed

TimeSpan between 2 dates removing weekends and holidays. #21

matjos opened this issue Sep 22, 2017 · 2 comments

Comments

@matjos
Copy link

matjos commented Sep 22, 2017

Example test.

        [TestMethod]
        public void TestTimeBetweenDatesRemovingHolidaysAndWeekends()
        {
            // Arrange
            var start = new DateTime(2017, 12, 22, 12, 00, 00);
            var end = new DateTime(2017, 12, 27, 12, 00, 00);

            // Act
            var result = new SwedenPublicHoliday().TimeBetweenDatesWithoutHolidaysAndWeekends(start, end);

            // Assert
            Assert.AreEqual(new TimeSpan(24, 0, 0), result);
        }
@martinjw
Copy link
Owner

We already use the term "WorkingDay" (in NextWorkingDay, PreviousWorkingDay).
In English, this usually means Monday-Friday, excluding weekends and holidays.
Of course there are businesses that work on Saturdays, and some on Sundays and holidays, but the conventional meaning excludes weekends. In German, Werktag legally means Monday-Saturday, but conventionally Saturdays are excluded.

So... I suggest holidays.WorkingDaysBetween(start, end);

Also I'd suggest returning an int, not a TimeSpan, as we only care about days, and spans over daylight savings time changes would be confusing.

@matjos
Copy link
Author

matjos commented Sep 22, 2017

I think i wanted a feature in your library that is not ment to be in your library. I solved what i wanted to accomplish with the help of your library. And that was to get elapsed time between two dates only counting time during workingdays(Mon-Fri) excluding holidays accuring on mon-fri. Thanks for a good library.

@matjos matjos closed this as completed Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants