In posts fetched from archives: display time as 4chan would format it.
This commit is contained in:
parent
cd1f12091e
commit
5fb3f244f5
@ -479,6 +479,42 @@
|
||||
}
|
||||
size = unit > 1 ? Math.round(size * 100) / 100 : Math.round(size);
|
||||
return "" + size + " " + ['B', 'KB', 'MB', 'GB'][unit];
|
||||
},
|
||||
isDST: function(d) {
|
||||
var date, day, hours, month, sunday;
|
||||
date = d.getUTCDate();
|
||||
day = d.getUTCDay();
|
||||
hours = d.getUTCHours();
|
||||
month = d.getUTCMonth();
|
||||
if (2 > month || month > 10) {
|
||||
return false;
|
||||
}
|
||||
if ((2 < month && month < 10)) {
|
||||
return true;
|
||||
}
|
||||
sunday = date - day;
|
||||
if (month === 2) {
|
||||
if (sunday < 8) {
|
||||
return false;
|
||||
}
|
||||
if (sunday < 15 && day === 0) {
|
||||
if (hours < 7) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (sunday < 1) {
|
||||
return true;
|
||||
}
|
||||
if (sunday < 8 && day === 0) {
|
||||
if (hours < 6) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@ -3096,7 +3132,9 @@
|
||||
});
|
||||
time = $('.dateTime', pi);
|
||||
date = new Date(data.timestamp * 1000);
|
||||
time.textContent = date.toString();
|
||||
date.setHours(date.getHours() + date.getTimezoneOffset() / 60 - 5 + 1 * $.isDST(date));
|
||||
Time.date = date;
|
||||
time.textContent = "" + (Time.formatters.m()) + "/" + (Time.formatters.d()) + "/" + (Time.formatters.y()) + "(" + (Time.formatters.a()) + ")" + (Time.formatters.H()) + ":" + (Time.formatters.M());
|
||||
$('.subject', pi).textContent = data.title;
|
||||
nameBlock = $('.nameBlock', pi);
|
||||
if (data.email) {
|
||||
@ -3187,7 +3225,7 @@
|
||||
});
|
||||
bq.innerHTML = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1<span class=quote>$2</span>$3');
|
||||
$.add(p, [piM, pi, bq]);
|
||||
if (data.media) {
|
||||
if (data.media_filename) {
|
||||
file = $.el('div', {
|
||||
id: "f" + postID,
|
||||
className: 'file'
|
||||
@ -3206,7 +3244,7 @@
|
||||
target: '_blank',
|
||||
innerHTML: "<img src=" + data.thumb_link + " alt='" + (data.spoiler === '1' ? 'Spoiler Image, ' : '') + filesize + "' data-md5=" + data.media_hash + " style='height: " + data.preview_h + "px; width: " + data.preview_w + "px;'>"
|
||||
}));
|
||||
$.after((isOP ? $('.postInfoM', p) : $('.postInfo', p)), file);
|
||||
$.after((isOP ? piM : pi), file);
|
||||
}
|
||||
$.replace(root.firstChild, pc);
|
||||
if (cb) {
|
||||
|
||||
@ -370,6 +370,60 @@ $.extend $,
|
||||
# Round to an integer otherwise.
|
||||
Math.round size
|
||||
"#{size} #{['B', 'KB', 'MB', 'GB'][unit]}"
|
||||
isDST: (d) ->
|
||||
# http://en.wikipedia.org/wiki/Eastern_Time_Zone
|
||||
# Its UTC time offset is −5 hrs (UTC−05) during standard time and −4
|
||||
# hrs (UTC−04) during daylight saving time.
|
||||
|
||||
# Since 2007, the local time changes at 02:00 EST to 03:00 EDT on the second
|
||||
# Sunday in March and returns at 02:00 EDT to 01:00 EST on the first Sunday
|
||||
# in November, in the U.S. as well as in Canada.
|
||||
|
||||
# 0200 EST (UTC-05) = 0700 UTC
|
||||
# 0200 EDT (UTC-04) = 0600 UTC
|
||||
|
||||
date = d.getUTCDate()
|
||||
day = d.getUTCDay()
|
||||
hours = d.getUTCHours()
|
||||
month = d.getUTCMonth()
|
||||
|
||||
# This is the easy part.
|
||||
if 2 > month or month > 10
|
||||
return false
|
||||
if 2 < month < 10
|
||||
return true
|
||||
|
||||
# (sunday's date) = (today's date) - (number of days past sunday)
|
||||
# date is not zero-indexed
|
||||
sunday = date - day
|
||||
|
||||
if month is 2
|
||||
# before second sunday
|
||||
if sunday < 8
|
||||
return false
|
||||
|
||||
# during second sunday
|
||||
if sunday < 15 and day is 0
|
||||
if hours < 7
|
||||
return false
|
||||
return true
|
||||
|
||||
# after second sunday
|
||||
return true
|
||||
|
||||
# month is 10
|
||||
# before first sunday
|
||||
if sunday < 1
|
||||
return true
|
||||
|
||||
# during first sunday
|
||||
if sunday < 8 and day is 0
|
||||
if hours < 6
|
||||
return true
|
||||
return false
|
||||
|
||||
# after first sunday
|
||||
return false
|
||||
|
||||
$.cache.requests = {}
|
||||
|
||||
@ -2400,8 +2454,12 @@ Get =
|
||||
innerHTML: "<input type=checkbox name=#{postID} value=delete> <span class=userInfo><span class=subject></span> <span class=nameBlock></span></span> <span class=dateTime data-utc=#{data.timestamp}></span> <span class='postNum desktop'><a href='/#{board}/res/#{data.thread_num}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{data.thread_num}#q#{postID}' title='Quote this post'>#{postID}</a>#{if isOP then ' ' else ''}</span> "
|
||||
# time
|
||||
time = $ '.dateTime', pi
|
||||
# UTC -> Local time
|
||||
date = new Date data.timestamp * 1000
|
||||
time.textContent = date.toString() # XXX needs to be 4chan formatted
|
||||
# Local time -> UTC -> EST/EDT (UTC-5/UTC-4)
|
||||
date.setHours date.getHours() + date.getTimezoneOffset() / 60 - 5 + 1 * $.isDST date
|
||||
Time.date = date
|
||||
time.textContent = "#{Time.formatters.m()}/#{Time.formatters.d()}/#{Time.formatters.y()}(#{Time.formatters.a()})#{Time.formatters.H()}:#{Time.formatters.M()}"
|
||||
# subject
|
||||
$('.subject', pi).textContent = data.title
|
||||
|
||||
@ -2486,7 +2544,7 @@ Get =
|
||||
|
||||
|
||||
# file
|
||||
if data.media
|
||||
if data.media_filename
|
||||
file = $.el 'div',
|
||||
id: "f#{postID}"
|
||||
className: 'file'
|
||||
@ -2506,7 +2564,7 @@ Get =
|
||||
href: data.media_link or data.remote_media_link
|
||||
target: '_blank'
|
||||
innerHTML: "<img src=#{data.thumb_link} alt='#{if data.spoiler is '1' then 'Spoiler Image, ' else ''}#{filesize}' data-md5=#{data.media_hash} style='height: #{data.preview_h}px; width: #{data.preview_w}px;'>"
|
||||
$.after (if isOP then $('.postInfoM', p) else $('.postInfo', p)), file
|
||||
$.after (if isOP then piM else pi), file
|
||||
|
||||
|
||||
$.replace root.firstChild, pc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user