Date format: match ordering of components in weechat
This commit is contained in:
parent
e65804c7a7
commit
79e77ffef0
|
@ -137,21 +137,39 @@ weechat.factory('connection',
|
||||||
angularFormat = short24;
|
angularFormat = short24;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for day of month in time string
|
// Assemble day of month
|
||||||
if (timeFormat.indexOf("%d") > -1 || timeFormat.indexOf("%e") > -1) {
|
var date_components = [];
|
||||||
angularFormat = "dd" + _timeDelimiter(" ") + angularFormat;
|
|
||||||
|
|
||||||
// month, too?
|
// Check for day of month in time format
|
||||||
if (timeFormat.indexOf("%m") > -1) {
|
var day_pos = Math.max(timeFormat.indexOf("%d"),
|
||||||
angularFormat = "MM" + _timeDelimiter("-") + angularFormat;
|
timeFormat.indexOf("%e"));
|
||||||
|
date_components.push([day_pos, "dd"]);
|
||||||
|
|
||||||
// year as well?
|
// month of year?
|
||||||
if (timeFormat.indexOf("%y") > -1) {
|
var month_pos = timeFormat.indexOf("%m");
|
||||||
angularFormat = "yy" + _timeDelimiter("-") + angularFormat;
|
date_components.push([month_pos, "MM"]);
|
||||||
} else if (timeFormat.indexOf("%Y") > -1) {
|
|
||||||
angularFormat = "yyyy" + _timeDelimiter("-") + angularFormat;
|
// year as well?
|
||||||
}
|
var year_pos = Math.max(timeFormat.indexOf("%y"),
|
||||||
|
timeFormat.indexOf("%Y"));
|
||||||
|
if (timeFormat.indexOf("%y") > -1) {
|
||||||
|
date_components.push([year_pos, "yy"]);
|
||||||
|
} else if (timeFormat.indexOf("%Y") > -1) {
|
||||||
|
date_components.push([year_pos, "yyyy"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there is a date, assemble it in the right order
|
||||||
|
if (date_components.length > 0) {
|
||||||
|
date_components.sort();
|
||||||
|
var format_array = [];
|
||||||
|
for (var i = 0; i < date_components.length; i++) {
|
||||||
|
if (date_components[i][0] == -1) continue;
|
||||||
|
format_array.push(date_components[i][1]);
|
||||||
}
|
}
|
||||||
|
// TODO: parse delimiter as well? For now, use '/' as it is
|
||||||
|
// more common internationally than '-'
|
||||||
|
var date_format = format_array.join(_timeDelimiter("/"));
|
||||||
|
angularFormat = date_format + _timeDelimiter(" ") + angularFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.angularTimeFormat = angularFormat;
|
$rootScope.angularTimeFormat = angularFormat;
|
||||||
|
|
Loading…
Reference in New Issue