mirror of
https://github.com/readest/readest.git
synced 2026-11-30 11:49:50 +00:00
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
Build with Nix / tests (push) Waiting to run
PR checks / nix_flake_check (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / koplugin_rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
* fix(koreader): improve reading progress sync * docs(koreader): document progress sync behavior and limitations * fix(koreader): harden sync auth, conflict handling, and error reporting * fix(koreader): keep non-auth 403 reasons and report the failed library sync step * fix(koreader): move backward on manual pull only to an exact position A manual pull could jump back when the remote xpointer only resolved after trimming to a parent node (a chapter start or /body), since a parent orders before its children. Manual pulls still go backward to an exact page or an xpointer that resolves untrimmed; a trimmed xpointer only ever moves forward. Automatic pulls stay forward-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * i18n(koreader): translate sync error messages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(koreader): report a pulled position whose chapter is missing Trimming an unresolvable xpointer fell back to /body, which resolves in any book, so a pull reported success for a position it could not use. Stop trimming above /body so such positions count as unusable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Sergey Ivanov <sergejs.ivanovs@applyit.lv> Co-authored-by: Huang Xin <chrox.huang@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.5 KiB
Lua
42 lines
1.5 KiB
Lua
-- Parse the server clock without interpreting UTC as device-local time.
|
|
local function iso_to_ms(s)
|
|
if not s then return nil end
|
|
if type(s) == "number" then return s end
|
|
if type(s) ~= "string" then return nil end
|
|
|
|
local y, mo, d, h, mi, sec, frac, tz = s:match(
|
|
"^(%d%d%d%d)%-(%d%d)%-(%d%d)[T ](%d%d):(%d%d):(%d%d)([%.%d]*)(.*)$")
|
|
if not y then return nil end
|
|
|
|
local t = os.time({
|
|
year = tonumber(y), month = tonumber(mo), day = tonumber(d),
|
|
hour = tonumber(h), min = tonumber(mi), sec = tonumber(sec),
|
|
isdst = false,
|
|
})
|
|
-- os.time interprets the struct as LOCAL time; convert to UTC by
|
|
-- subtracting the local TZ offset.
|
|
local utc_offset = os.difftime(t, os.time(os.date("!*t", t)))
|
|
t = t + utc_offset
|
|
|
|
-- Apply the input's own offset (Z = +00:00; "+05:30" subtracts 5.5h to
|
|
-- get UTC). Default to UTC if no offset present (server contract).
|
|
if tz and tz ~= "" and tz ~= "Z" then
|
|
local sign, oh, om = tz:match("^([%+%-])(%d%d):?(%d%d)$")
|
|
if sign then
|
|
local off = (tonumber(oh) * 3600) + (tonumber(om or 0) * 60)
|
|
if sign == "+" then t = t - off else t = t + off end
|
|
end
|
|
end
|
|
|
|
local ms = t * 1000
|
|
if frac and frac:sub(1, 1) == "." then
|
|
-- Fractional seconds: take only the first 3 digits (ms precision)
|
|
local f = frac:sub(2, 4)
|
|
if #f > 0 then
|
|
ms = ms + tonumber(f .. string.rep("0", 3 - #f))
|
|
end
|
|
end
|
|
return ms
|
|
end
|
|
|
|
return iso_to_ms
|