Sanchayan Maity
5c80b85d69
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.
14 lines
382 B
VimL
14 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>
|