diff options
author | James McCoy <jamessan@jamessan.com> | 2021-12-26 09:42:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-26 09:42:52 -0500 |
commit | 2b0be9eff8463bc22f631f65c95d6ac21e4090bc (patch) | |
tree | 84152d5dd8967c427ab441ef1bd9ece3c809d6d4 | |
parent | 8c720f6b9d3217e2a9449ce13aac02406edbbb4e (diff) | |
parent | fb14e2a8d6aacfb02578c2e191f26cfdf416bfde (diff) | |
download | rneovim-2b0be9eff8463bc22f631f65c95d6ac21e4090bc.tar.gz rneovim-2b0be9eff8463bc22f631f65c95d6ac21e4090bc.tar.bz2 rneovim-2b0be9eff8463bc22f631f65c95d6ac21e4090bc.zip |
Merge pull request #16788 from jamessan/strptime-fix
fix(msgpack#strptime): use calendar.timegm to get seconds since epoch
-rw-r--r-- | runtime/autoload/msgpack.vim | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim index 7dd225e3d9..7f98a5b230 100644 --- a/runtime/autoload/msgpack.vim +++ b/runtime/autoload/msgpack.vim @@ -56,6 +56,7 @@ function s:msgpack_init_python() abort \. " time = datetime.datetime.fromtimestamp(timestamp)\n" \. " return time.strftime(fmt)\n" \. "def shada_dict_strptime():\n" + \. " import calendar\n" \. " import datetime\n" \. " import vim\n" \. " fmt = vim.eval('a:format')\n" @@ -64,7 +65,10 @@ function s:msgpack_init_python() abort \. " try:\n" \. " timestamp = int(timestamp.timestamp())\n" \. " except:\n" - \. " timestamp = int(timestamp.strftime('%s'))\n" + \. " try:\n" + \. " timestamp = int(timestamp.strftime('%s'))\n" + \. " except:\n" + \. " timestamp = calendar.timegm(timestamp.utctimetuple())\n" \. " if timestamp > 2 ** 31:\n" \. " tsabs = abs(timestamp)\n" \. " return ('{\"_TYPE\": v:msgpack_types.integer,'\n" |