dotfiles/nvim/.config/nvim/plugin/epoch-converter.vim
Sanchayan Maity 5c80b85d69 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.
2022-04-15 11:09:29 +05:30

15 lines
382 B
VimL

function GetHumanReadableDate()
normal! `<v`>y
let date = trim(system("date -d @" . trim(shellescape(@@))))
echo date
endfunction
function GetEpochDate()
normal! `<v`>y
let date = trim(system("date -d " . trim(shellescape(@@)) . ' "+%s"'))
echo date
endfunction
xnoremap <LocalLeader>e :call GetHumanReadableDate()<CR>
xnoremap <LocalLeader>E :call GetEpochDate()<CR>