Determine which day of the week is selected with Date Picker Calendar

I’m trying to display only relevant courses from a data collection based on which date (or more specifically day of the week) a user selects through the date picker calendar. I’m curious to know if the Date Picker API maps each day of the week to an array of numbers by default or if I have to figure out a way to do that with code.

Looking through the API documentation, the function disabledDaysOfWeek assigns the days of the week as an array of integers from 0 to 6, with 0 representing Sunday. Can I assume this arrangement is default for my use case?

My plan is to give each course in the data collection a field key reference number 0-6 depending on which day of the week the course is offered. Then using an onChange and data query have the date selected pair to the reference number in the data collection and display only the items that correspond with the day of the week selected.

I have some pseudo code written down but I’m wondering if anyone has a better understanding of how to accomplish this?

const dayPicked = $w("#datePicker1").value
const dayAsNumber = dayPicked.getDay()

This formats the day chosen in the calendar into a number, 0 representing Sunday, which I can use with a data query to find the matching services offered for that date.