Skip to content

Instantly share code, notes, and snippets.

@sudara
Created August 23, 2009 22:05
Show Gist options
  • Select an option

  • Save sudara/173480 to your computer and use it in GitHub Desktop.

Select an option

Save sudara/173480 to your computer and use it in GitHub Desktop.
SC.RecordAttribute.registerTransform(SC.DateTime, {
/** Transforms a date to an integer of milliseconds since 1970 */
/** @private - convert an int to a date */
to: function(n, attr) {
/* Transform a date coming from rails in the format 2008/12/31 10:45:23 +0200 */
return SC.DateTime.parse(n,'%Y/%m/%d %H:%M:%S');
},
/** @private - convert a date to an int */
from: function(date) {
return date.get('milliseconds');
}
});
SC.Query.registerComparison('created_at', function(d1,d2){
/** Use SC.DateTime.compare() for date properties */
return SC.DateTime.compare(d1,d2);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment