A very lightweight date range picker using jQuery
This is a very simple and lightweight date range picker. It is extensible but not highly configurable. Do not expect a feature rich widget, rather a base upon which something can be built per requirement. Thanks to Karl Seguin for his excellent work.
Shortcuts configuration property is an array of objects with two properties 'element' and 'callback'. The 'element' property will contain the text to be displayed and the callback a function which returns a date range. For example:
shortcuts: [
{
'element': 'This Month',
'callback': function () {
var today = new Date(),
from = new Date(today.getFullYear(), today.getMonth(), 1, 0, 0, 0),
to = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
return [from, today];
}
},
{
'element': 'Last Month',
'callback': function () {
var today = new Date(),
from = new Date(today.getFullYear(), today.getMonth() - 1, 1, 0, 0, 0),
to = new Date(today.getFullYear(), today.getMonth(), 0, 0, 0, 0);
return [from, to];
}
}
]
jQuery 1.6.1 (though I have not tested it with lower versions)