Skip to content

Instantly share code, notes, and snippets.

@codersatx
Created June 11, 2011 02:06
Show Gist options
  • Save codersatx/1020158 to your computer and use it in GitHub Desktop.
Save codersatx/1020158 to your computer and use it in GitHub Desktop.
Some code to manipulate the jQuery UI calendar.
$(document).ready(function(){
var today = new Date();
today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // Zero time components
var tomorrow = today.getDay() + 1;
var next_two_days = today.getDay() + 2;
var next_three_days = today.getDay() + 3;
var curr_time = getTime();
var curr_day = today.getDate();
$(".datepicker").datepicker({
numberOfMonths: 1,
showButtonPanel: true,
showOn: 'button',
buttonImage: '/themes/public/basic/images/calendar.png',
buttonImageOnly: true,
dateFormat: 'yy-mm-dd',
beforeShowDay: function(date) {
var day = date.getDay();
if(curr_time > '5:00 PM')
{
return [(day != 0 && day != tomorrow && day != next_two_days && day != next_three_days && date.getDate() >= curr_day), ''];
}
else
{
return [(day != 0 && day != tomorrow && day != next_two_days && date.getDate() >= curr_day), ''];
}
}
});
function getTime() {
var dTime = new Date();
var hours = dTime.getHours();
var minute = dTime.getMinutes();
var period = "AM";
if (hours > 12)
{
period = "PM"
}
else
{
period = "AM";
}
hours = ((hours > 12) ? hours - 12 : hours)
return hours + ":" + minute + " " + period
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment