.getDay() (of a Date object) method:
- 0 is Sunday
- 1 is Monday
- 2 is Tuesday
- 3 is Wednesday
- 4 is Thursday
- 5 is Friday
- 6 is Saturday
(Not the coding below, but the array position above)
Date object only. To construct a new date:
It's related to index of an array. If we have
In English, "weekday" is any day of the week other than Sunday (and Saturday). "Working day" in another words *twinkle twinkle*
Anyhow, you can leave the input argument to be empty or undefined to get current month's Sundays.
It will be array of integers.
For instance, November 2018, will yield
[4, 11, 18, 25]
If you look the calendar, November 4, 2018 is Sunday, and so the 11th, 18th, and 25th
In Python, Sunday is at index 6. Because Python is a name of a gigantic snake before it became a TV show then a programming language, so it doesn't have correlation with earlier sentence. What sentence?
.weekday() (of a datetime object) method:
- 0 is Monday
- 1 is Tuesday
- 2 is Wednesday
- 3 is Thursday
- 4 is Friday
- 5 is Saturday
- 6 is Sunday
Input type must be date object. Or, you can leave it empty to get current month.
In Python, the month integer is the same as the actual Gregorian. December is 12, September is 9, March is 3, January is 1, and all. Any integer from 1 to 12.
Only weekday is using 0. Any integer from 0 to 6, where 0 is Monday, 6 is Sunday.
It's up to you, whatever modification of input / process / output that suits your progrem. In this post, I shared my new learning of "looping weekly". I suppose the concept can be broadened and applied to other matters, not just calendar related.
How about public holidays?
Well, we need a regularly updated database of course and read that list. Every country has its own different holidays. There're services we can use, free or paid, for instance Google Calendar or TimeAndDate, or others. Some countries (government sites) provide free access to get the list of holidays of current year, perhaps. I mean like an API, not just displaying it on the site's page. But not every country.
Or, we could create our own DB "manually".