Skip to content

Commit

Permalink
Merge pull request miguelfreitas#377 from miguelfreitas/blaster
Browse files Browse the repository at this point in the history
sync with blaster
  • Loading branch information
miguelfreitas committed Jan 15, 2018
2 parents 43d3169 + 80fb930 commit f4f120c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2015 Miguel Freitas, Lucas Leal and twister project developers.
Copyright (c) 2013-2018 Miguel Freitas, Lucas Leal and twister project developers.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
27 changes: 26 additions & 1 deletion js/interface_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ var twister = {
modal: {},
res: {}, // reses for various reqs are cached here
var: {
dateFormatter: {
format: function (req) {
return req.toString().replace(/GMT.*/g, '');
}
},
localAccounts: [],
updatesCheckClient: {}
}
Expand Down Expand Up @@ -406,7 +411,26 @@ function timeGmtToText(t) {
if (t == 0) return '-';
var d = new Date(0);
d.setUTCSeconds(t);
return d.toString().replace(/GMT.*/g, '');
return twister.var.dateFormatter.format(d);
}

function setupTimeGmtToText(lang) {
if (typeof window.Intl !== 'object' || typeof window.Intl.DateTimeFormat !== 'function')
return;

twister.var.dateFormatter = new Intl.DateTimeFormat(
knownLanguages.indexOf(lang) !== -1 ? lang : undefined,
{
hour12: false,
weekday: 'short',
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
}
);
}

function timeSincePost(t) {
Expand Down Expand Up @@ -2889,6 +2913,7 @@ function setTextcompleteDropdownListPos(position) {
}

$(document).ready(function () {
setupTimeGmtToText($.Options.locLang.val);
if ($.localStorage.isSet('twistaURIs'))
twister.URIs = $.localStorage.get('twistaURIs');
twister.html.blanka.appendTo('body').hide();
Expand Down
6 changes: 6 additions & 0 deletions js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ function twisterOptions() {
if (elem.value !== 'auto')
twisterRpc('setpreferredspamlang', [elem.value]);
location.reload();
/*
if (elem.value !== 'auto') {
setupTimeGmtToText(elem.value);
TODO redraw all timestamps
}
*/
},
tickNotOnInit: 1
});
Expand Down

0 comments on commit f4f120c

Please sign in to comment.