diff --git a/js/connection.js b/js/connection.js index e20a29e..419de16 100644 --- a/js/connection.js +++ b/js/connection.js @@ -77,6 +77,10 @@ weechat.factory('connection', ); }; + var _timeDelimiter = function(delim) { + return "'" + delim + "'"; + }; + var _parseWeechatTimeFormat = function() { // Fetch the buffer time format from weechat var timeFormat = models.wconfig['weechat.look.buffer_time_format']; @@ -88,7 +92,7 @@ weechat.factory('connection', // one of four formats, (short|long) (12|24)-hour time var angularFormat = ""; - var timeDelimiter = "':'"; + var timeDelimiter = _timeDelimiter(":"); var left12 = "hh" + timeDelimiter + "mm"; var right12 = "' 'a"; @@ -132,6 +136,19 @@ weechat.factory('connection', angularFormat = short24; } + if (timeFormat.indexOf("%d") > -1) { + angularFormat = "dd" + _timeDelimiter(" ") + angularFormat; + if (timeFormat.indexOf("%m") > -1) { + angularFormat = "MM" + _timeDelimiter("-") + angularFormat; + if (timeFormat.indexOf("%y") > -1) { + angularFormat = "yy" + _timeDelimiter("-") + angularFormat; + } + if (timeFormat.indexOf("%Y") > -1) { + angularFormat = "yyyy" + _timeDelimiter("-") + angularFormat; + } + } + } + $rootScope.angularTimeFormat = angularFormat; };