diff --git a/copyparty/__main__.py b/copyparty/__main__.py
index 97944c13..609a534e 100644
--- a/copyparty/__main__.py
+++ b/copyparty/__main__.py
@@ -1548,6 +1548,7 @@ def add_ui(ap, retry):
ap2 = ap.add_argument_group('ui options')
ap2.add_argument("--grid", action="store_true", help="show grid/thumbnails by default (volflag=grid)")
ap2.add_argument("--gsel", action="store_true", help="select files in grid by ctrl-click (volflag=gsel)")
+ ap2.add_argument("--localtime", action="store_true", help="default to local timezone instead of UTC")
ap2.add_argument("--lang", metavar="LANG", type=u, default="eng", help="language; one of the following: \033[32meng nor chi\033[0m")
ap2.add_argument("--theme", metavar="NUM", type=int, default=0, help="default theme to use (0..7)")
ap2.add_argument("--themes", metavar="NUM", type=int, default=8, help="number of themes installed")
diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py
index 28441114..030209fe 100644
--- a/copyparty/authsrv.py
+++ b/copyparty/authsrv.py
@@ -2775,6 +2775,7 @@ class AuthSrv(object):
"dth3x": vf["th3x"],
"dvol": self.args.au_vol,
"idxh": int(self.args.ih),
+ "dutc": not self.args.localtime,
"themes": self.args.themes,
"turbolvl": self.args.turbo,
"nosubtle": self.args.nosubtle,
diff --git a/copyparty/svchub.py b/copyparty/svchub.py
index 73855bf1..bd7562e4 100644
--- a/copyparty/svchub.py
+++ b/copyparty/svchub.py
@@ -1026,6 +1026,8 @@ class SvcHub(object):
except:
raise Exception("invalid --mv-retry [%s]" % (self.args.mv_retry,))
+ al.js_utc = "false" if al.localtime else "true"
+
al.tcolor = al.tcolor.lstrip("#")
if len(al.tcolor) == 3: # fc5 => ffcc55
al.tcolor = "".join([x * 2 for x in al.tcolor])
diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js
index 17fe489a..0f9d7698 100644
--- a/copyparty/web/browser.js
+++ b/copyparty/web/browser.js
@@ -230,6 +230,7 @@ var Ls = {
"ct_qdel": 'when deleting files, only ask for confirmation once">qdel',
"ct_dir1st": 'sort folders before files">📁 first',
"ct_nsort": 'natural sort (for filenames with leading digits)">nsort',
+ "ct_utc": 'show all datetimes in UTC">UTC',
"ct_readme": 'show README.md in folder listings">📜 readme',
"ct_idxh": 'show index.html instead of folder listing">htm',
"ct_sbars": 'show scrollbars">⟊',
@@ -857,6 +858,7 @@ var Ls = {
"ct_qdel": 'sletteknappen spør bare én gang om bekreftelse">hurtig🗑️',
"ct_dir1st": 'sorter slik at mapper kommer foran filer">📁 først',
"ct_nsort": 'naturlig sortering (forstår tall i filnavn)">nsort',
+ "ct_utc": 'bruk UTC for alle klokkeslett">UTC',
"ct_readme": 'vis README.md nedenfor filene">📜 readme',
"ct_idxh": 'vis index.html istedenfor fil-liste">htm',
"ct_sbars": 'vis rullgardiner / skrollefelt">⟊',
@@ -1483,6 +1485,7 @@ var Ls = {
"ct_qdel": '删除文件时,只需确认一次">快删', //m
"ct_dir1st": '在文件之前排序文件夹">📁 排序',
"ct_nsort": '正确排序以数字开头的文件名">数字排序', //m
+ "ct_utc": '所有时间请使用UTC">UTC', //m
"ct_readme": '在文件夹列表中显示 README.md">📜 readme',
"ct_idxh": '显示 index.html 代替文件夹列表">htm',
"ct_sbars": '显示滚动条">⟊',
@@ -2109,6 +2112,7 @@ var Ls = {
"ct_qdel": 'Nur einmal fragen, wenn mehrere Dateien gelöscht werden">qdel',
"ct_dir1st": 'Ordner vor Dateien sortieren">📁 zuerst',
"ct_nsort": 'Natürliche Sortierung (für Dateinamen mit führenden Ziffern)">nsort',
+ "ct_utc": 'Verwenden Sie UTC für alle Zeitangaben">UTC', //m
"ct_readme": 'README.md in Dateiliste anzeigen">📜 readme',
"ct_idxh": 'index.html anstelle von Dateiliste anzeigen">htm',
"ct_sbars": 'Scrollbars zeigen">⟊',
@@ -3362,6 +3366,7 @@ var Ls = {
"ct_qdel": 'спрашивать подтверждение только один раз перед удалением файлов">быстр. удал.',
"ct_dir1st": 'разместить папки над файлами">📁 сверху',
"ct_nsort": 'сортировка по числам$N(например, файл с >code<2>/code< в начале названия идёт перед >code<11>/code<)">нат. сорт.',
+ "ct_utc": 'используйте UTC для всех временных меток">UTC', //m
"ct_readme": 'показывать содержимое README.md в описании папки">📜 ридми',
"ct_idxh": 'показывать страницу index.html в текущей папке вместо интерфейса">htm',
"ct_sbars": 'показывать полосы прокрутки">⟊',
@@ -3987,6 +3992,7 @@ var Ls = {
"ct_qdel": 'al eliminar archivos, pedir confirmación solo una vez">elim. rápida',
"ct_dir1st": 'ordenar carpetas antes que archivos">📁 primero',
"ct_nsort": 'orden natural (para nombres de archivo con dígitos iniciales)">ord. natural',
+ "ct_utc": 'use UTC para todas las horas">UTC', //m
"ct_readme": 'mostrar README.md en los listados de carpetas">📜 léeme',
"ct_idxh": 'mostrar index.html en lugar del listado de carpetas">htm',
"ct_sbars": 'mostrar barra lateral">⟊',
@@ -4613,6 +4619,7 @@ var Ls = {
"ct_qdel": 'при видаленні файлів, запитати підтвердження лише один раз">швидке видалення',
"ct_dir1st": 'сортувати папки перед файлами">спочатку 📁',
"ct_nsort": 'природне сортування (для імен файлів з початковими цифрами)">природне сортування',
+ "ct_utc": 'використовуйте UTC для всіх часових позначень">UTC', //m
"ct_readme": 'показати README.md у списках папок">📜 readme',
"ct_idxh": 'показати index.html замість списку папки">htm',
"ct_sbars": 'показати смуги прокрутки">⟊',
@@ -5232,6 +5239,7 @@ ebi('op_cfg').innerHTML = (
'
' + sv;
}
- ln = ln.concat([tn.ext, unix2iso(tn.ts)]).join(' | ');
+ ln = ln.concat([tn.ext, unix2ui(tn.ts)]).join(' | ');
html.push(ln + ' | ');
}
html.push('');
@@ -13184,7 +13196,7 @@ var unpost = (function () {
var done = res[a].pd === undefined;
html.push(
'' + (done ? L.un_del : L.un_abrt) + ' | ' +
- '' + unix2iso(res[a].at) + ' | ' +
+ '' + unix2ui(res[a].at) + ' | ' +
'' + ('' + res[a].sz).replace(/\B(?=(\d{3})+(?!\d))/g, " ") + ' | ' +
(done ? '100% | ' : '' + res[a].pd + '% | ') +
'' + linksplit(res[a].vp).join(' / ') + ' |
');
diff --git a/copyparty/web/rups.html b/copyparty/web/rups.html
index 5d286cae..af90eefe 100644
--- a/copyparty/web/rups.html
+++ b/copyparty/web/rups.html
@@ -33,6 +33,7 @@
var SR="{{ r }}",
lang="{{ lang }}",
+ dutc={{ this.args.js_utc }},
dfavico="{{ favico }}";
var STG = window.localStorage;
diff --git a/copyparty/web/rups.js b/copyparty/web/rups.js
index e476f0fe..9559be8c 100644
--- a/copyparty/web/rups.js
+++ b/copyparty/web/rups.js
@@ -10,7 +10,7 @@ function render() {
fn = esc(uricom_dec(vsp[1])),
at = f.at,
td = now - f.at,
- ts = !at ? '(?)' : unix2iso(at),
+ ts = !at ? '(?)' : unix2ui(at),
sa = !at ? '(?)' : td > 60 ? shumantime(td) : (td + 's'),
sz = ('' + f.sz).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
diff --git a/copyparty/web/shares.html b/copyparty/web/shares.html
index 9c7dcd27..381fe853 100644
--- a/copyparty/web/shares.html
+++ b/copyparty/web/shares.html
@@ -66,6 +66,7 @@
var SR="{{ r }}",
shr="{{ shr }}",
lang="{{ lang }}",
+ dutc={{ this.args.js_utc }},
dfavico="{{ favico }}";
var STG = window.localStorage;
diff --git a/copyparty/web/shares.js b/copyparty/web/shares.js
index e3faf029..d14dfeb7 100644
--- a/copyparty/web/shares.js
+++ b/copyparty/web/shares.js
@@ -66,7 +66,7 @@ function showqr(href) {
for (var b = 7; b < 9; b++) {
var v = buf[ibuf++];
tr[a].cells[b].innerHTML =
- v ? unix2iso(v).replace(' ', ', ') : 'never';
+ v ? unix2ui(v).replace(' ', ', ') : 'never';
}
for (var a = 0; a < tr.length; a++)
diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js
index edf0eee8..2f588446 100644
--- a/copyparty/web/up2k.js
+++ b/copyparty/web/up2k.js
@@ -2511,8 +2511,8 @@ function up2k_init(subtle) {
var msg = [];
for (var a = 0, aa = Math.min(20, response.hits.length); a < aa; a++) {
var hit = response.hits[a],
- tr = unix2iso(hit.ts),
- tu = unix2iso(t.lmod),
+ tr = unix2ui(hit.ts),
+ tu = unix2ui(t.lmod),
diff = parseInt(t.lmod) - parseInt(hit.ts),
cdiff = (Math.abs(diff) <= 2) ? '3c0' : 'f0b',
sdiff = 'diff ' + diff;
@@ -3187,7 +3187,7 @@ function up2k_init(subtle) {
return;
try {
- ebi('lifew').innerHTML = unix2iso((st.lifetime || lifetime) +
+ ebi('lifew').innerHTML = unix2ui((st.lifetime || lifetime) +
Date.now() / 1000 - new Date().getTimezoneOffset() * 60
).replace(' ', ', ').slice(0, -3);
}
diff --git a/copyparty/web/util.js b/copyparty/web/util.js
index b246e145..94f73f24 100644
--- a/copyparty/web/util.js
+++ b/copyparty/web/util.js
@@ -907,11 +907,29 @@ function noq_href(el) {
}
+function pad2(v) {
+ return ('0' + v).slice(-2);
+}
+
+
function unix2iso(ts) {
return new Date(ts * 1000).toISOString().replace("T", " ").slice(0, -5);
}
+function unix2iso_localtime(ts) {
+ var o = new Date(ts * 1000),
+ p = pad2;
+ return "{0}-{1}-{2} {3}:{4}:{5}".format(
+ o.getFullYear(),
+ p(o.getMonth() + 1),
+ p(o.getDate()),
+ p(o.getHours()),
+ p(o.getMinutes()),
+ p(o.getSeconds()));
+}
+
+
function s2ms(s) {
s = Math.floor(s);
var m = Math.floor(s / 60);
@@ -1203,6 +1221,13 @@ function scfg_bind(obj, oname, cname, defval, cb) {
}
+window.unix2ui = (function () {
+ var v = sread('utctid');
+ v = v ? (v === '0') : (window.dutc === false);
+ return v ? unix2iso_localtime : unix2iso;
+})();
+
+
function hist_push(url) {
console.log("h-push " + url);
try {
diff --git a/tests/util.py b/tests/util.py
index 8027c372..42a47907 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -143,7 +143,7 @@ class Cfg(Namespace):
def __init__(self, a=None, v=None, c=None, **ka0):
ka = {}
- ex = "chpw cookie_lax daw dav_auth dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only ih ihead magic nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_tail no_tarcmp no_thumb no_vthumb no_zip nrand nsort nw og og_no_head og_s_title ohead q rand re_dirsz reflink rmagic rss smb srch_dbg srch_excl stats uqe vague_403 vc ver wo_up_readme write_uplog xdev xlink xvol zipmaxu zs"
+ ex = "chpw cookie_lax daw dav_auth dav_mac dav_rt e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp early_ban ed emp exp force_js getmod grid gsel hardlink hardlink_only ih ihead localtime magic nid nih no_acode no_athumb no_bauth no_clone no_cp no_dav no_db_ip no_del no_dirsz no_dupe no_lifetime no_logues no_mv no_pipe no_poll no_readme no_robots no_sb_md no_sb_lg no_scandir no_tail no_tarcmp no_thumb no_vthumb no_zip nrand nsort nw og og_no_head og_s_title ohead q rand re_dirsz reflink rmagic rss smb srch_dbg srch_excl stats uqe vague_403 vc ver wo_up_readme write_uplog xdev xlink xvol zipmaxu zs"
ka.update(**{k: False for k in ex.split()})
ex = "dav_inf dedup dotpart dotsrch hook_v no_dhash no_fastboot no_fpool no_htp no_rescan no_sendfile no_ses no_snap no_up_list no_voldump re_dhash see_dots plain_ip"