Fix QDateTime conversions
- Qt 5.7 doesn't have QDateTime::(from|to)SecsSinceEpoch, so we need to use the msecs variant instead. - We were passing a float which causes a TypeError (rather than being truncated to an int) with newer PyQt versions.
This commit is contained in:
parent
f8e83dcaa1
commit
9bdcea42de
|
|
@ -223,10 +223,10 @@ def _qdatetime_to_completion_format(qdate):
|
|||
if not qdate.isValid():
|
||||
ts = 0
|
||||
else:
|
||||
ts = qdate.toSecsSinceEpoch()
|
||||
ts = qdate.toMSecsSinceEpoch()
|
||||
if ts < 0:
|
||||
ts = 0
|
||||
pydate = datetime.datetime.fromtimestamp(ts)
|
||||
pydate = datetime.datetime.fromtimestamp(ts / 1000)
|
||||
return pydate.strftime(config.val.completion.timestamp_format)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1211,7 +1211,8 @@ def tab_with_history(fake_web_tab, tabbed_browser_stubs, info, monkeypatch):
|
|||
entry = mock.Mock(spec=QWebEngineHistoryItem)
|
||||
entry.url.return_value = QUrl(url)
|
||||
entry.title.return_value = title
|
||||
entry.lastVisited.return_value = QDateTime.fromSecsSinceEpoch(ts)
|
||||
dt = QDateTime.fromMSecsSinceEpoch(int(ts * 1000))
|
||||
entry.lastVisited.return_value = dt
|
||||
history.append(entry)
|
||||
tab.history._history = mock.Mock(spec=QWebEngineHistory)
|
||||
tab.history._history.items.return_value = history
|
||||
|
|
|
|||
Loading…
Reference in New Issue