AM/PM localized time. Close #5
This commit is contained in:
parent
f86b6049a0
commit
171d0f1974
10
4chan_x.js
10
4chan_x.js
@ -104,6 +104,7 @@
|
|||||||
'Anonymize': [false, 'Make everybody anonymous'],
|
'Anonymize': [false, 'Make everybody anonymous'],
|
||||||
'Keybinds': [false, 'Binds actions to keys'],
|
'Keybinds': [false, 'Binds actions to keys'],
|
||||||
'Localize Time': [true, 'Show times based on your timezone'],
|
'Localize Time': [true, 'Show times based on your timezone'],
|
||||||
|
'Localized am/pm': [false, 'Change localized time to the 12-hour clock convention'],
|
||||||
'Report Button': [true, 'Add report buttons'],
|
'Report Button': [true, 'Add report buttons'],
|
||||||
'Comment Expansion': [true, 'Expand too long comments'],
|
'Comment Expansion': [true, 'Expand too long comments'],
|
||||||
'Thread Expansion': [true, 'View all replies'],
|
'Thread Expansion': [true, 'View all replies'],
|
||||||
@ -1640,7 +1641,7 @@
|
|||||||
localize = {
|
localize = {
|
||||||
init: function() {
|
init: function() {
|
||||||
return g.callbacks.push(function(root) {
|
return g.callbacks.push(function(root) {
|
||||||
var date, day, dotw, hour, min_sec, month, s, span, year, _, _i, _len, _ref, _ref2, _results;
|
var date, day, dotw, hour, meridiem, min_sec, month, s, span, year, _, _i, _len, _ref, _ref2, _results;
|
||||||
_ref = $$('span[id^=no]', root);
|
_ref = $$('span[id^=no]', root);
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
@ -1650,13 +1651,18 @@
|
|||||||
year = "20" + year;
|
year = "20" + year;
|
||||||
month -= 1;
|
month -= 1;
|
||||||
hour = g.chanOffset + Number(hour);
|
hour = g.chanOffset + Number(hour);
|
||||||
|
meridiem = '';
|
||||||
|
if ($.config('Localized am/pm')) {
|
||||||
|
meridiem = hour < 12 ? ' a.m.' : ' p.m.';
|
||||||
|
hour = hour === 0 ? 12 : hour > 12 ? hour - 12 : void 0;
|
||||||
|
}
|
||||||
date = new Date(year, month, day, hour);
|
date = new Date(year, month, day, hour);
|
||||||
year = date.getFullYear() - 2000;
|
year = date.getFullYear() - 2000;
|
||||||
month = $.zeroPad(date.getMonth() + 1);
|
month = $.zeroPad(date.getMonth() + 1);
|
||||||
day = $.zeroPad(date.getDate());
|
day = $.zeroPad(date.getDate());
|
||||||
hour = $.zeroPad(date.getHours());
|
hour = $.zeroPad(date.getHours());
|
||||||
dotw = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
|
dotw = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][date.getDay()];
|
||||||
_results.push(s.textContent = " " + month + "/" + day + "/" + year + "(" + dotw + ")" + hour + ":" + min_sec + " ");
|
_results.push(s.textContent = " " + month + "/" + day + "/" + year + "(" + dotw + ")" + hour + ":" + min_sec + meridiem + " ");
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,6 +42,7 @@ config =
|
|||||||
'Anonymize': [false, 'Make everybody anonymous']
|
'Anonymize': [false, 'Make everybody anonymous']
|
||||||
'Keybinds': [false, 'Binds actions to keys']
|
'Keybinds': [false, 'Binds actions to keys']
|
||||||
'Localize Time': [true, 'Show times based on your timezone']
|
'Localize Time': [true, 'Show times based on your timezone']
|
||||||
|
'Localized am/pm': [false, 'Change localized time to the 12-hour clock convention']
|
||||||
'Report Button': [true, 'Add report buttons']
|
'Report Button': [true, 'Add report buttons']
|
||||||
'Comment Expansion': [true, 'Expand too long comments']
|
'Comment Expansion': [true, 'Expand too long comments']
|
||||||
'Thread Expansion': [true, 'View all replies']
|
'Thread Expansion': [true, 'View all replies']
|
||||||
@ -1329,6 +1330,10 @@ localize =
|
|||||||
year = "20#{year}"
|
year = "20#{year}"
|
||||||
month -= 1 #months start at 0
|
month -= 1 #months start at 0
|
||||||
hour = g.chanOffset + Number hour
|
hour = g.chanOffset + Number hour
|
||||||
|
meridiem = ''
|
||||||
|
if $.config 'Localized am/pm'
|
||||||
|
meridiem = if hour < 12 then ' a.m.' else ' p.m.'
|
||||||
|
hour = if hour is 0 then 12 else if hour > 12 then hour - 12
|
||||||
date = new Date year, month, day, hour
|
date = new Date year, month, day, hour
|
||||||
year = date.getFullYear() - 2000
|
year = date.getFullYear() - 2000
|
||||||
month = $.zeroPad date.getMonth() + 1
|
month = $.zeroPad date.getMonth() + 1
|
||||||
@ -1343,7 +1348,7 @@ localize =
|
|||||||
'Fri'
|
'Fri'
|
||||||
'Sat'
|
'Sat'
|
||||||
][date.getDay()]
|
][date.getDay()]
|
||||||
s.textContent = " #{month}/#{day}/#{year}(#{dotw})#{hour}:#{min_sec} "
|
s.textContent = " #{month}/#{day}/#{year}(#{dotw})#{hour}:#{min_sec}#{meridiem} "
|
||||||
|
|
||||||
titlePost =
|
titlePost =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user