Skip to content

Commit

Permalink
Merge branch 'datepicker' into aegisdemo3
Browse files Browse the repository at this point in the history
Conflicts:
	datepicker-rewrite/date.js
	datepicker-rewrite/index.html
	datepicker-rewrite/picker.js
  • Loading branch information
hanshillen committed Mar 24, 2012
2 parents f54e47c + de6e41b commit 3344a5b
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 295 deletions.
205 changes: 0 additions & 205 deletions datepicker-rewrite/alternative-template.html

This file was deleted.

22 changes: 12 additions & 10 deletions datepicker-rewrite/date.js
Expand Up @@ -6,22 +6,19 @@
*/
(function( $, undefined ) {

if ( typeof( $.global.culture ) == "undefined" ) {
$.global.culture = $.global.cultures[ "default" ];
}

$.date = function ( datestring, formatstring ) {
var calendar = $.global.culture.calendar,
//TODO: Need to refactor $.date to be a constructor, move the methods to a prototype.
var calendar = Globalize.culture().calendar,
format = formatstring ? formatstring : calendar.patterns.d,
date = datestring ? $.global.parseDate(datestring, format) : new Date();
date = datestring ? Globalize.parseDate(datestring, format) : new Date();

if ( !date ) {
date = new Date()
}

return {
refresh: function() {
calendar = $.global.culture.calendar;
calendar = Globalize.culture().calendar;
format = formatstring || calendar.patterns.d;
return this;
},
Expand All @@ -31,6 +28,8 @@ $.date = function ( datestring, formatstring ) {
}
return this;
},
//TODO: same as the underlying Date object's terminology, but still misleading.
//TODO: We can use .setTime() instead of new Date and rename to setTimestamp.
setTime: function( time ) {
date = new Date( time );
return this;
Expand All @@ -40,10 +39,13 @@ $.date = function ( datestring, formatstring ) {
return this;
},
setMonth: function( month ) {
//TODO: Should update this to keep the time component (hour, min, sec) intact. Same for setYear and setFullDate.
//TODO: Do we want to do any special handling when switching to a month that causes the days to overflow?
date = new Date( date.getFullYear(), month, date.getDate());
return this;
},
setYear: function( year ) {
//TODO: Same question as setMonth, but I suppose only for leap years.
date = new Date( year, date.getMonth(), date.getDate() );
return this;
},
Expand Down Expand Up @@ -107,7 +109,7 @@ $.date = function ( datestring, formatstring ) {
var day = week.days[ week.days.length ] = {
lead: printDate.getMonth() != date.getMonth(),
date: printDate.getDate(),
timeStamp: printDate.getTime(),
timestamp: printDate.getTime(),
current: this.selected && this.selected.equal( printDate ),
today: today.equal( printDate )
};
Expand Down Expand Up @@ -155,15 +157,15 @@ $.date = function ( datestring, formatstring ) {
// TODO compare year, month, day each for better performance
equal: function( other ) {
function format( date ) {
return $.global.format( date, "d" );
return Globalize.format( date, "d" );
}
return format( date ) == format( other );
},
date: function() {
return date;
},
format: function( formatstring ) {
return $.global.format( date, formatstring ? formatstring : format );
return Globalize.format( date, formatstring ? formatstring : format );
},
calendar: function( newcalendar ) {
if ( newcalendar ) {
Expand Down

0 comments on commit 3344a5b

Please sign in to comment.