aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/msgpack_spec.lua
diff options
context:
space:
mode:
authorVolodymyr Chernetskyi <volodymyr_chernetskyi@goodyear.com>2026-09-07 14:24:16 +0200
committerGitHub <noreply@github.com>2026-09-07 08:24:16 -0400
commita31f9affde680d1b93b1283955764d247ee3bb4d (patch)
treeb6988e89599fabb8b2742b2f18cd572cdf88649c /test/functional/plugin/msgpack_spec.lua
parent1c8d5581d93cb22076273d114d78c44f8ce9720c (diff)
downloadrneovim-a31f9affde680d1b93b1283955764d247ee3bb4d.tar.gz
rneovim-a31f9affde680d1b93b1283955764d247ee3bb4d.tar.bz2
rneovim-a31f9affde680d1b93b1283955764d247ee3bb4d.zip
fix(msgpack): strptime() fails east of UTC+12 #41743
Problem: msgpack#strptime() finds a timestamp by bisecting strftime() output, and brackets the search with the extreme UTC offsets. The lower bound subtracts 12 hours, but -12:00 is the westernmost offset, which produces the *largest* timestamp for a given local time. The easternmost offset is +14:00, so in any zone east of UTC+12 the search can start above the target and the function throws: internal-start-string:Internal error: start > string With TZ=GMT-14, four of the five timestamps in msgpack_spec.lua fail, as do three tests in shada_spec.lua, which reaches the same function through shada#strings_to_sd(). Solution: Subtract 14 hours instead. The upper bound is already generous enough at +14, and widening a bisection bracket downwards cannot change the result in zones that worked before. The test disables the python3 provider, because msgpack#strptime() only uses the Vimscript implementation changed here when no provider answers, and otherwise hands the work to datetime.strptime(). AI-assisted
Diffstat (limited to 'test/functional/plugin/msgpack_spec.lua')
-rw-r--r--test/functional/plugin/msgpack_spec.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/functional/plugin/msgpack_spec.lua b/test/functional/plugin/msgpack_spec.lua
index a2255a3855..6e9467e159 100644
--- a/test/functional/plugin/msgpack_spec.lua
+++ b/test/functional/plugin/msgpack_spec.lua
@@ -735,3 +735,25 @@ describe('autoload/msgpack.vim', function()
end)
end)
end)
+
+describe('autoload/msgpack.vim in an eastern timezone', function()
+ setup(function()
+ clear({
+ -- msgpack#strptime() prefers a Python implementation and only falls back to the
+ -- Vimscript one, which is the one under test, when no provider answers.
+ args = { '-u', 'NORC', '--cmd', 'let g:loaded_python3_provider = 0' },
+ -- POSIX TZ signs are inverted: GMT-14 is UTC+14, the easternmost offset.
+ env = { TZ = 'GMT-14' },
+ })
+ end)
+
+ describe('function msgpack#strptime', function()
+ it('works east of UTC+12 #7625', function()
+ eq(0, nvim_eval('has("python3")'))
+ for _, v in ipairs({ 0, 10, 100000, 204, 1000000000 }) do
+ local time = nvim_eval(('strftime("%%Y-%%m-%%dT%%H:%%M:%%S", %d)'):format(v))
+ eq(v, nvim_eval(('msgpack#strptime("%%Y-%%m-%%dT%%H:%%M:%%S", "%s")'):format(time)))
+ end
+ end)
+ end)
+end)