{"id":10936,"date":"2022-11-08T13:43:46","date_gmt":"2022-11-08T18:43:46","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=10936"},"modified":"2022-11-08T13:43:46","modified_gmt":"2022-11-08T18:43:46","slug":"counting-working-days","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=10936","title":{"rendered":"Counting Working Days"},"content":{"rendered":"<p>Here\u2019s a small problem to think about: how many working days are there in this month or, more generally, between any two dates? \u201cWorking days\u201d means Monday through Friday minus holidays. It\u2019s not a hard problem but think how you would solve it. There\u2019s certainly no formula like that for <a href=\"https:\/\/en.wikipedia.org\/wiki\/Determination_of_the_day_of_the_week#Mathematical_algorithms\">calculating the day of the week on a given date<\/a> but even consigning yourself to brute forcing the calculation there\u2019s no obvious trivial solution.<\/p>\n<p>Marcin Borkowski (mbork) has an <a href=\"http:\/\/mbork.pl\/2022-11-07_Counting_working_days_again\">interesting post that details his solution<\/a>. His solution is for the number of working days in a given month but wouldn\u2019t be too hard to generalize to the number of working days between two arbitrary dates. His method is truly brute force. He pushes the weekend days onto a list, adds any other days off such as holidays occurring during the month, counts the size of the list, and subtracts the result from the number of days in the month. The extra days off are specified manually so that he can add personal days off and account for differences in holidays between countries.<\/p>\n<p>As Mbork says, the real lesson from all this is how flexible Emacs is and what a nice environment it provides for writing little helper functions. Take a look at his post and see if you don\u2019t agree.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here\u2019s a small problem to think about: how many working days are there in this month or, more generally, between any two dates? \u201cWorking days\u201d means Monday through Friday minus holidays. It\u2019s not a hard problem but think how you &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=10936\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-10936","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10936"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10936\/revisions"}],"predecessor-version":[{"id":10937,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/10936\/revisions\/10937"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}