Closed bshepherdson closed 8 years ago
Feeding it any date results in:
<property name="birthday"> <object> <property name="toRelativeDateString">function toRelativeDateString(){ var seconds = Math.floor((Date.now() - this.getTime())/1000); if ( seconds < 60 ) return 'moments ago'; var minutes = Math.floor((seconds)/60); if ( minutes == 1 ) return '1 minute ago'; if ( minutes < 60 ) return minutes + ' minutes ago'; var hours = Math.floor(minutes/60); if ( hours == 1 ) return '1 hour ago'; if ( hours < 24 ) return hours + ' hours ago'; var days = Math.floor(hours / 24); if ( days == 1 ) return '1 day ago'; if ( days < 7 ) return days + ' days ago'; if ( days < 365 ) { var year = 1900+this.getYear(); var noyear = this.toDateString().replace(' ' + year, ''); return noyear.substring(4); } return this.toDateString().substring(4); } </property> <property name="equals">function equals(o) { if ( ! o ) return false; if ( ! o.getTime ) return false; return this.getTime() === o.getTime(); } </property> <property name="compareTo">function compareTo(o){ if ( o === this ) return 0; if ( ! o ) return 1; var d = this.getTime() - o.getTime(); return d == 0 ? 0 : d > 0 ? 1 : -1; } </property> <property name="toMQL">function toMQL() { return this.getFullYear() + '/' + (this.getMonth() + 1) + '/' + this.getDate(); } </property> <property name="toBQL">function toBQL() { var str = this.toISOString(); // eg. 2014-12-04T16:37:33.420Z return str.substring(0, str.indexOf('.')); // eg. 2014-12-04T16:37:33 } </property> </object> </property>
Feeding it any date results in: