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.
This commit is contained in:
Sanchayan Maity 2022-04-15 11:09:29 +05:30
parent 7e0060eacb
commit 5c80b85d69

View file

@ -1,6 +1,6 @@
function GetHumanReadableDate()
let epoch = expand("<cword>")
let date = trim(system("date -d @" . epoch))
normal! `<v`>y
let date = trim(system("date -d @" . trim(shellescape(@@))))
echo date
endfunction
@ -10,5 +10,5 @@ function GetEpochDate()
echo date
endfunction
nnoremap <LocalLeader>e :call GetHumanReadableDate()<CR>
xnoremap <LocalLeader>e :call GetEpochDate()<CR>
xnoremap <LocalLeader>e :call GetHumanReadableDate()<CR>
xnoremap <LocalLeader>E :call GetEpochDate()<CR>