Sanchayan Maity
2e8f138f8b
We look at logs frequently these days with epoch timestamps and this helps with getting the human readable timestamp and vice versa.
14 lines
381 B
VimL
14 lines
381 B
VimL
function GetHumanReadableDate()
|
|
let epoch = expand("<cword>")
|
|
let date = trim(system("date -d @" . epoch))
|
|
echo date
|
|
endfunction
|
|
|
|
function GetEpochDate()
|
|
normal! `<v`>y
|
|
let date = trim(system("date -d " . trim(shellescape(@@)) . ' "+%s"'))
|
|
echo date
|
|
endfunction
|
|
|
|
nnoremap <LocalLeader>e :call GetHumanReadableDate()<CR>
|
|
xnoremap <LocalLeader>e :call GetEpochDate()<CR>
|