mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge pull request #16788 from jamessan/strptime-fix
fix(msgpack#strptime): use calendar.timegm to get seconds since epoch
This commit is contained in:
		| @@ -56,6 +56,7 @@ function s:msgpack_init_python() abort | |||||||
|               \. "  time = datetime.datetime.fromtimestamp(timestamp)\n" |               \. "  time = datetime.datetime.fromtimestamp(timestamp)\n" | ||||||
|               \. "  return time.strftime(fmt)\n" |               \. "  return time.strftime(fmt)\n" | ||||||
|               \. "def shada_dict_strptime():\n" |               \. "def shada_dict_strptime():\n" | ||||||
|  |               \. "  import calendar\n" | ||||||
|               \. "  import datetime\n" |               \. "  import datetime\n" | ||||||
|               \. "  import vim\n" |               \. "  import vim\n" | ||||||
|               \. "  fmt = vim.eval('a:format')\n" |               \. "  fmt = vim.eval('a:format')\n" | ||||||
| @@ -64,7 +65,10 @@ function s:msgpack_init_python() abort | |||||||
|               \. "  try:\n" |               \. "  try:\n" | ||||||
|               \. "    timestamp = int(timestamp.timestamp())\n" |               \. "    timestamp = int(timestamp.timestamp())\n" | ||||||
|               \. "  except:\n" |               \. "  except:\n" | ||||||
|  |               \. "    try:\n" | ||||||
|               \. "      timestamp = int(timestamp.strftime('%s'))\n" |               \. "      timestamp = int(timestamp.strftime('%s'))\n" | ||||||
|  |               \. "    except:\n" | ||||||
|  |               \. "      timestamp = calendar.timegm(timestamp.utctimetuple())\n" | ||||||
|               \. "  if timestamp > 2 ** 31:\n" |               \. "  if timestamp > 2 ** 31:\n" | ||||||
|               \. "    tsabs = abs(timestamp)\n" |               \. "    tsabs = abs(timestamp)\n" | ||||||
|               \. "    return ('{\"_TYPE\": v:msgpack_types.integer,'\n" |               \. "    return ('{\"_TYPE\": v:msgpack_types.integer,'\n" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 James McCoy
					James McCoy