diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim index fb438def4f..421c2f2ac5 100644 --- a/runtime/autoload/msgpack.vim +++ b/runtime/autoload/msgpack.vim @@ -132,11 +132,11 @@ function s:msgpack_init_python() abort let [year, month, day, hour, minute, second] = match[1:6] " Bisection start and end: " - " Start: 365 days in year, 28 days in month, -12 hours tz offset. + " Start: 365 days in year, 28 days in month, -14 hours tz offset. let bisect_ts_start = (((((year - 1970) * 365 \+ (month - 1) * 28 \+ (day - 1)) * 24 - \+ hour - 12) * 60 + \+ hour - 14) * 60 \+ minute) * 60 \+ second) if bisect_ts_start < 0 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)