mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
/// <reference path="daterangepicker.d.ts"/>
|
|
|
|
function tests_simple() {
|
|
$('#daterange').daterangepicker();
|
|
$('input[name="daterange"]').daterangepicker({
|
|
timePicker: true,
|
|
timePickerIncrement: 30,
|
|
locale: {
|
|
format: 'MM/DD/YYYY h:mm A'
|
|
}
|
|
});
|
|
|
|
$('#reportrange').daterangepicker({
|
|
ranges: {
|
|
'Today': [moment(), moment()],
|
|
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
}
|
|
});
|
|
|
|
$('input[name="datefilter"]').on('apply.daterangepicker', function (ev, picker) {
|
|
$(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
|
|
});
|
|
|
|
|
|
$('input[name="datefilter"]').on('cancel.daterangepicker', function (ev, picker) {
|
|
$(this).val('');
|
|
});
|
|
|
|
$('#demo').daterangepicker({
|
|
"startDate": "05/06/2016",
|
|
"endDate": "05/12/2016"
|
|
}, function (start: string, end: string, label: string) {
|
|
console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')");
|
|
});
|
|
|
|
$(function() {
|
|
|
|
function cb(start: moment.Moment, end: moment.Moment) {
|
|
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
|
|
}
|
|
cb(moment().subtract(29, 'days'), moment());
|
|
|
|
$('#reportrange').daterangepicker({
|
|
ranges: {
|
|
'Today': [moment(), moment()],
|
|
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
}
|
|
}, cb);
|
|
|
|
});
|
|
}
|