fix timezone in search, zipfiles, fuse

This commit is contained in:
ed 2022-05-15 13:51:44 +02:00
parent e7cd922d8b
commit 715401ca8e
5 changed files with 15 additions and 11 deletions

View File

@ -42,6 +42,7 @@ import threading
import traceback import traceback
import http.client # py2: httplib import http.client # py2: httplib
import urllib.parse import urllib.parse
import calendar
from datetime import datetime from datetime import datetime
from urllib.parse import quote_from_bytes as quote from urllib.parse import quote_from_bytes as quote
from urllib.parse import unquote_to_bytes as unquote from urllib.parse import unquote_to_bytes as unquote
@ -495,7 +496,7 @@ class Gateway(object):
ts = 60 * 60 * 24 * 2 ts = 60 * 60 * 24 * 2
try: try:
sz = int(fsize) sz = int(fsize)
ts = datetime.strptime(fdate, "%Y-%m-%d %H:%M:%S").timestamp() ts = calendar.timegm(time.strptime(fdate, "%Y-%m-%d %H:%M:%S"))
except: except:
info("bad HTML or OS [{}] [{}]".format(fdate, fsize)) info("bad HTML or OS [{}] [{}]".format(fdate, fsize))
# python cannot strptime(1959-01-01) on windows # python cannot strptime(1959-01-01) on windows

View File

@ -45,6 +45,7 @@ import threading
import traceback import traceback
import http.client # py2: httplib import http.client # py2: httplib
import urllib.parse import urllib.parse
import calendar
from datetime import datetime from datetime import datetime
from urllib.parse import quote_from_bytes as quote from urllib.parse import quote_from_bytes as quote
from urllib.parse import unquote_to_bytes as unquote from urllib.parse import unquote_to_bytes as unquote
@ -443,7 +444,7 @@ class Gateway(object):
ts = 60 * 60 * 24 * 2 ts = 60 * 60 * 24 * 2
try: try:
sz = int(fsize) sz = int(fsize)
ts = datetime.strptime(fdate, "%Y-%m-%d %H:%M:%S").timestamp() ts = calendar.timegm(time.strptime(fdate, "%Y-%m-%d %H:%M:%S"))
except: except:
info("bad HTML or OS [{}] [{}]".format(fdate, fsize)) info("bad HTML or OS [{}] [{}]".format(fdate, fsize))
# python cannot strptime(1959-01-01) on windows # python cannot strptime(1959-01-01) on windows

View File

@ -3,7 +3,7 @@ from __future__ import print_function, unicode_literals
import time import time
import zlib import zlib
from datetime import datetime import calendar
from .sutil import errdesc from .sutil import errdesc
from .util import yieldfile, sanitize_fn, spack, sunpack, min_ex from .util import yieldfile, sanitize_fn, spack, sunpack, min_ex
@ -25,8 +25,8 @@ def dostime2unix(buf):
tf = "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}" tf = "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}"
iso = tf.format(*tt) iso = tf.format(*tt)
dt = datetime.strptime(iso, "%Y-%m-%d %H:%M:%S") dt = time.strptime(iso, "%Y-%m-%d %H:%M:%S")
return int(dt.timestamp()) return int(calendar.timegm(dt))
def unixtime2dos(ts): def unixtime2dos(ts):

View File

@ -4,8 +4,8 @@ from __future__ import print_function, unicode_literals
import re import re
import os import os
import time import time
import calendar
import threading import threading
from datetime import datetime
from operator import itemgetter from operator import itemgetter
from .__init__ import ANYWIN, unicode from .__init__ import ANYWIN, unicode
@ -190,18 +190,17 @@ class U2idx(object):
if is_date: if is_date:
is_date = False is_date = False
v = v.upper().rstrip("Z").replace(",", " ").replace("T", " ") v = re.sub(r"[tzTZ, ]+", " ", v).strip()
while " " in v:
v = v.replace(" ", " ")
for fmt in [ for fmt in [
"%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M:%S",
"%Y-%m-%d %H:%M", "%Y-%m-%d %H:%M",
"%Y-%m-%d %H", "%Y-%m-%d %H",
"%Y-%m-%d", "%Y-%m-%d",
"%Y-%m",
"%Y",
]: ]:
try: try:
v = datetime.strptime(v, fmt).timestamp() v = calendar.timegm(time.strptime(v, fmt))
break break
except: except:
pass pass

View File

@ -4056,6 +4056,9 @@ document.onkeydown = function (e) {
vs = ebi('srch_' + k + 'v').value, vs = ebi('srch_' + k + 'v').value,
tvs = []; tvs = [];
if (a == 1)
vs = vs.trim().replace(/ +/, 'T');
while (vs) { while (vs) {
vs = vs.trim(); vs = vs.trim();
if (!vs) if (!vs)