mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:30:01 +00:00
Convert edited timestamp to local time
This commit is contained in:
parent
0b094a7229
commit
faf7548cd0
|
@ -449,6 +449,11 @@ class CommentBase(DeclarativeHelperBase):
|
||||||
''' Returns a UTC POSIX timestamp, as seconds '''
|
''' Returns a UTC POSIX timestamp, as seconds '''
|
||||||
return (self.created_time - UTC_EPOCH).total_seconds()
|
return (self.created_time - UTC_EPOCH).total_seconds()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def edited_utc_timestamp(self):
|
||||||
|
''' Returns a UTC POSIX timestamp, as seconds '''
|
||||||
|
return (self.edited_time - UTC_EPOCH).total_seconds() if self.edited_time else 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def editable_until(self):
|
def editable_until(self):
|
||||||
return self.created_utc_timestamp + config['EDITING_TIME_LIMIT']
|
return self.created_utc_timestamp + config['EDITING_TIME_LIMIT']
|
||||||
|
|
|
@ -174,6 +174,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
var target = timestamp_targets[i];
|
var target = timestamp_targets[i];
|
||||||
var torrent_timestamp = parseInt(target.getAttribute('data-timestamp'));
|
var torrent_timestamp = parseInt(target.getAttribute('data-timestamp'));
|
||||||
var swap_flag = target.getAttribute('data-timestamp-swap') != null;
|
var swap_flag = target.getAttribute('data-timestamp-swap') != null;
|
||||||
|
var title_flag = target.getAttribute('data-timestamp-title') != null;
|
||||||
|
|
||||||
if (torrent_timestamp) {
|
if (torrent_timestamp) {
|
||||||
var timedelta = now_timestamp - torrent_timestamp;
|
var timedelta = now_timestamp - torrent_timestamp;
|
||||||
|
@ -182,10 +183,14 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
var formatted_timedelta = _format_time_difference(timedelta);
|
var formatted_timedelta = _format_time_difference(timedelta);
|
||||||
if (swap_flag) {
|
if (swap_flag) {
|
||||||
target.setAttribute('title', formatted_date);
|
target.setAttribute('title', formatted_date);
|
||||||
target.innerText = formatted_timedelta;
|
if (!title_flag) {
|
||||||
|
target.innerText = formatted_timedelta;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
target.setAttribute('title', formatted_timedelta);
|
target.setAttribute('title', formatted_timedelta);
|
||||||
target.innerText = formatted_date;
|
if (!title_flag) {
|
||||||
|
target.innerText = formatted_date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -156,7 +156,7 @@
|
||||||
<div class="row comment-details">
|
<div class="row comment-details">
|
||||||
<a href="#com-{{ loop.index }}"><small data-timestamp-swap data-timestamp="{{ comment.created_utc_timestamp|int }}">{{ comment.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</small></a>
|
<a href="#com-{{ loop.index }}"><small data-timestamp-swap data-timestamp="{{ comment.created_utc_timestamp|int }}">{{ comment.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</small></a>
|
||||||
{% if comment.edited_time %}
|
{% if comment.edited_time %}
|
||||||
<small title="{{ comment.edited_time }}">(edited)</small>
|
<small data-timestamp-swap data-timestamp-title data-timestamp="{{ comment.edited_utc_timestamp }}" title="{{ comment.edited_time }}">(edited)</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="comment-actions">
|
<div class="comment-actions">
|
||||||
{% if g.user.id == comment.user_id and not comment.editing_limit_exceeded %}
|
{% if g.user.id == comment.user_id and not comment.editing_limit_exceeded %}
|
||||||
|
|
Loading…
Reference in a new issue