Created
June 5, 2025 09:32
-
-
Save aimahdi/b96b52b3e4cecc76a571f1b3803f7957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload= function () { | |
flatpickr('.fp', { | |
enableTime: true, | |
dateFormat: "Y-m-d H:i", | |
onReady: updateLimits, | |
onChange: updateLimits | |
}); | |
function updateLimits(selectedDates, dateStr, instance) { | |
const day = (selectedDates[0] || new Date()).getDay(); | |
const timeLimits = { | |
0: ['10:00', '14:00'], // Sunday | |
1: ['09:00', '17:00'], | |
2: ['09:00', '17:00'], | |
3: ['09:00', '17:00'], | |
4: ['09:00', '17:00'], | |
5: ['09:00', '17:00'], | |
6: ['11:00', '15:00'] // Saturday | |
}; | |
const [min, max] = timeLimits[day]; | |
instance.set('minTime', min); | |
instance.set('maxTime', max); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment