javascript - Get first and fifth business day for each month -
any example of code or function tell if indicative date 1st or 5th business day of current month.
business days monday - friday
example. passing current date of format yyyy-mm-dd
function or code return true if current date corresponds 1st or 5th business day.
my interest piqued question.
this no means perfect, did ok in quick tests. should invoke getnthbusinessday(5, 9, 2014)
5th working day of sept 2014. in case returns text friday
etc, etc
var days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]; function getnthbusinessday(n, month, year) { var worked = 0; (var = 1; <= 31; i++) { var testdate = new date(year, month - 1, i); var day = testdate.getday(); if (day > 0 && day < 6) { if (++worked == n) { return days[day]; } } } }
Comments
Post a Comment