From 5c80b85d699117527ec4405b55302a8b356b53d7 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Fri, 15 Apr 2022 11:09:29 +0530 Subject: [PATCH] nvim: plugin/epoch-converter: Fix timestamp conversion helper The epoch time under cursor may be in milliseconds or seconds. Use visual selection to select epoch since we won't know which. Else when the epoch was in milliseconds we would just get wrong results. --- nvim/.config/nvim/plugin/epoch-converter.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nvim/.config/nvim/plugin/epoch-converter.vim b/nvim/.config/nvim/plugin/epoch-converter.vim index fc77f0d..8fe3e80 100644 --- a/nvim/.config/nvim/plugin/epoch-converter.vim +++ b/nvim/.config/nvim/plugin/epoch-converter.vim @@ -1,6 +1,6 @@ function GetHumanReadableDate() - let epoch = expand("") - let date = trim(system("date -d @" . epoch)) + normal! `y + let date = trim(system("date -d @" . trim(shellescape(@@)))) echo date endfunction @@ -10,5 +10,5 @@ function GetEpochDate() echo date endfunction -nnoremap e :call GetHumanReadableDate() -xnoremap e :call GetEpochDate() +xnoremap e :call GetHumanReadableDate() +xnoremap E :call GetEpochDate()