fixed bug with startDate

This commit is contained in:
Valeriy 2014-08-06 11:25:50 +06:00
parent a7880e783a
commit 00695940df
2 changed files with 20 additions and 13 deletions

View File

@ -14,7 +14,7 @@
<body> <body>
<p><a href="http://xdsoft.net/jqplugins/datetimepicker/">Homepage</a></p> <p><a href="http://xdsoft.net/jqplugins/datetimepicker/">Homepage</a></p>
<h3>DateTimePicker</h3> <h3>DateTimePicker</h3>
<input type="text" value="2014/03/15 05:06" id="datetimepicker"/><br><br> <input type="text" value="" id="datetimepicker"/><br><br>
<h3>Mask DateTimePicker</h3> <h3>Mask DateTimePicker</h3>
<input type="text" value="" id="datetimepicker_mask"/><br><br> <input type="text" value="" id="datetimepicker_mask"/><br><br>
<h3>TimePicker</h3> <h3>TimePicker</h3>
@ -53,6 +53,13 @@
<script src="./jquery.js"></script> <script src="./jquery.js"></script>
<script src="./jquery.datetimepicker.js"></script> <script src="./jquery.datetimepicker.js"></script>
<script> <script>
$('#datetimepicker').datetimepicker({
dayOfWeekStart : 1,
lang:'ru',
startDate: '1986/01/05'
});
//$('#datetimepicker').datetimepicker({value:'2015/04/15 05:03',step:10});
/*
$('#default_datetimepicker').datetimepicker({ $('#default_datetimepicker').datetimepicker({
formatTime:'H:i', formatTime:'H:i',
formatDate:'d.m.Y', formatDate:'d.m.Y',
@ -67,11 +74,7 @@ $('#datetimepicker10').datetimepicker({
$('#datetimepicker_mask').datetimepicker({ $('#datetimepicker_mask').datetimepicker({
mask:'9999/19/39 29:59' mask:'9999/19/39 29:59'
}); });
$('#datetimepicker').datetimepicker({
dayOfWeekStart : 1,
lang:'ru'
});
$('#datetimepicker').datetimepicker({value:'2015/04/15 05:03',step:10});
$('#datetimepicker1').datetimepicker({ $('#datetimepicker1').datetimepicker({
datepicker:false, datepicker:false,
format:'H:i', format:'H:i',
@ -164,6 +167,6 @@ $('#datetimepicker12').datetimepicker({
return [true, ""]; return [true, ""];
} }
}); });*/
</script> </script>
</html> </html>

View File

@ -746,7 +746,7 @@
var d = new Date(); var d = new Date();
if( !norecursion && options.defaultDate ){ if( !norecursion && options.defaultDate ){
var date = _this.strtodate(options.defaultDate); var date = _this.strToDate(options.defaultDate);
d.setFullYear( date.getFullYear() ); d.setFullYear( date.getFullYear() );
d.setMonth( date.getMonth() ); d.setMonth( date.getMonth() );
d.setDate( date.getDate() ); d.setDate( date.getDate() );
@ -839,7 +839,7 @@
return currentTime; return currentTime;
}; };
_this.strtodate = function( sDate ) { _this.strToDate = function( sDate ) {
if( sDate && sDate instanceof Date && _this.isValidDate(sDate) ) if( sDate && sDate instanceof Date && _this.isValidDate(sDate) )
return sDate; return sDate;
@ -962,12 +962,12 @@
var maxDate = false, minDate = false; var maxDate = false, minDate = false;
if( options.maxDate!==false ) { if( options.maxDate!==false ) {
maxDate = _xdsoft_datetime.strtodate(options.maxDate); maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999); maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);
} }
if( options.minDate!==false ) { if( options.minDate!==false ) {
minDate = _xdsoft_datetime.strtodate(options.minDate); minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate()); minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
} }
@ -1327,10 +1327,14 @@
var ct = false; var ct = false;
if ( options.startDate ) { if ( options.startDate ) {
ct = _xdsoft_datetime.strToDateTime(options.startDate); ct = _xdsoft_datetime.strToDate(options.startDate);
} else { } else {
ct = options.value?options.value:(input&&input.val&&input.val())?input.val():''; ct = options.value?options.value:(input&&input.val&&input.val())?input.val():'';
ct = Date.parseDate(ct, options.format); if( ct ) {
ct = _xdsoft_datetime.strToDateTime(ct);
} else if ( options.defaultDate ) {
ct = _xdsoft_datetime.strToDate(options.defaultDate);
}
} }
if ( ct && _xdsoft_datetime.isValidDate(ct) ) { if ( ct && _xdsoft_datetime.isValidDate(ct) ) {