ok( $.ui.date( null, attributes ) instanceof $.ui.date, "instantiation without new" );
});
-test( "Check Sets and Gets", 6, function() {
+test( "Check Sets and Gets", 4, function() {
var date = $.ui.date( null, attributes );
- equal( date.setYear( 2012 ).year(), 2012, "Set year and retrieve" );
- equal( date.setMonth( 9 ).month(), 9, "Set month and retrieve" );
equal( date.setDay( 15 ).day(), 15, "Set day and retrieve" );
equal( date.setFullDate( 2012, 9, 15 ).year(), 2012, "Set full date and retrieve year" );
equal( date.month(), 9, "Set full date and retrieve month" );
equal( date.day(), 15, "Set full date and retrieve day" );
+ // TODO Add setTime test
});
test( "Date Adjustments - Normal Use Cases", 10, function() {
deepEqual( date.weekdays(), offset1, "Get weekdays with start of day on 1 (Germany)" );
});
-test( "Leap Year Check", 8, function() {
- var date = $.ui.date( null, attributes );
- ok( date.setYear( 2008 ).isLeapYear(), "2008 is a Leap Year" );
- ok( !date.setYear( 2009 ).isLeapYear(), "2009 is not a Leap Year" );
- ok( !date.setYear( 2010 ).isLeapYear(), "2010 is not a Leap Year" );
- ok( !date.setYear( 2011 ).isLeapYear(), "2011 is not a Leap Year" );
- ok( date.isLeapYear( 2012 ), "2012 is a Leap Year" );
- ok( !date.isLeapYear( 2013 ), "2013 is not a Leap Year" );
- ok( !date.isLeapYear( 2014 ), "2014 is not a Leap year" );
- ok( !date.isLeapYear( 2015 ), "2015 is not a Leap year" );
-});
-
test( "Days in Month", 3, function() {
var date = $.ui.date( null, attributes );
date.setFullDate( 2012, 1, 1 );
test( "Month Name", 2, function() {
var date = $.ui.date( null, attributes );
- equal( date.setMonth( 3 ).monthName(), "April", "Month name return April (English)" );
+ equal( date.setFullDate( 2012, 3, 1 ).monthName(), "April", "Month name return April (English)" );
date = $.ui.date( null, testHelper.getAttributes( "de" ) );
- equal( date.setMonth( 2 ).monthName(), "März", "Month name return March (German)" );
+ equal( date.setFullDate( 2012, 2, 1 ).monthName(), "März", "Month name return March (German)" );
});
test( "Clone", 2, function() {
});
test( "Days", 1, function() {
- // TODO needs work
+ // TODO Needs work
var date = $.ui.date( null, attributes );
date.eachDay = function( day ) {
if ( day.lead && day.date > 20 ) {
return this;
},
- setMonth: function( month ) {
-
- // Overflow example: Month is October 31 (yeah Halloween) and month is changed to April with 30 days,
- // the new date will me May 1. We will honor the month the user wants to set and if and overflow
- // occurs, set to last day of month.
- var date = this.dateObject,
- days = date.getDate(), year = date.getFullYear();
- if ( days > this.daysInMonth( year, month ) ) {
-
- // Overflow
- days = this.daysInMonth( year, month );
- }
- this.dateObject = new Date( year, month, days, date.getHours(),
- date.getMinutes(), date.getSeconds() );
- return this;
- },
-
- setYear: function( year ) {
- var date = this.dateObject,
- day = date.getDate(),
- month = date.getMonth();
-
- // Check if Leap, and February and day is 29th
- if ( this.isLeapYear( year ) && month === 1 && day === 29 ) {
-
- // set day to last day of February
- day = this.daysInMonth( year, month );
- }
- this.dateObject = new Date( year, month, day, date.getHours(),
- date.getMinutes(), date.getSeconds() );
- return this;
- },
setFullDate: function( year, month, day ) {
this.dateObject = new Date( year, month, day );
return this.dateObject.getFullYear();
},
- isLeapYear: function( year ) {
- year = year || this.dateObject.getFullYear();
- return new Date( year, 1, 29 ).getMonth() === 1;
- },
-
weekdays: function() {
var date,
firstDay = this.firstDay,