@ -30,23 +30,49 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
// plus one day will be time 00:00:00
old _date _plus _one . setHours ( 0 , 0 , 0 , 0 ) ;
var content = "\u001943" + // styling
"Date changed to " + new _date . toDateString ( ) ;
var content = "\u001943" ; // this colour corresponds to chat_day_change
content += new _date . toLocaleDateString ( window . navigator . language ,
{ weekday : "long" } ) ;
// if you're testing different date formats,
// make sure to test different locales such as "en-US",
// "en-US-u-ca-persian" (which has different weekdays, year 0, and an ERA)
// "ja-JP-u-ca-persian-n-thai" (above, diff numbering, diff text)
var extra _date _format = {
day : "numeric" ,
month : "long"
} ;
if ( new _date . getYear ( ) !== old _date . getYear ( ) ) {
extra _date _format . year = "numeric" ;
}
content += " (" ;
content += new _date . toLocaleDateString ( window . navigator . language ,
extra _date _format ) ;
// Result should be something like
// Friday (November 27)
// or if the year is different,
// Friday (November 27, 2015)
// Comparing dates in javascript is beyond tedious
if ( old _date _plus _one . valueOf ( ) !== new _date . valueOf ( ) ) {
var date _diff = Math . round ( ( new _date - old _date ) / ( 24 * 60 * 60 * 1000 ) ) ;
var date _diff = Math . round ( ( new _date - old _date ) / ( 24 * 60 * 60 * 1000 ) ) + 1 ;
if ( date _diff < 0 ) {
date _diff = - 1 * ( date _diff + 1 ) ;
content += " (" + date _diff + " days before " + old _date . toDateString ( ) + ")" ;
date _diff = - 1 * ( date _diff ) ;
if ( date _diff === 1 ) {
content += ", 1 day before" ;
} else {
content += ", " + date _diff + " days before" ;
}
} else {
content += " (" + date _diff + " days have passed since " + old _date . toDateString ( ) + ")" ;
content += ", " + date _diff + " days la ter" ;
}
// Result: Friday (November 27, 5 days later)
}
content += ")" ;
var line = {
buffer : buffer ,
date : new _date ,
prefix : '\u001943\u2500\u2500' ,
prefix : '\u001943\u2500' ,
tags _array : [ ] ,
displayed : true ,
highlight : 0 ,