From 2e8f138f8ba972e727decde1030d4c539eaaf80d Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 14 Mar 2022 11:04:23 +0530 Subject: [PATCH] nvim: plugin: Add a plugin to help with epoch timestamp conversions We look at logs frequently these days with epoch timestamps and this helps with getting the human readable timestamp and vice versa. --- nvim/.config/nvim/plugin/epoch-converter.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nvim/.config/nvim/plugin/epoch-converter.vim diff --git a/nvim/.config/nvim/plugin/epoch-converter.vim b/nvim/.config/nvim/plugin/epoch-converter.vim new file mode 100644 index 0000000..fc77f0d --- /dev/null +++ b/nvim/.config/nvim/plugin/epoch-converter.vim @@ -0,0 +1,14 @@ +function GetHumanReadableDate() + let epoch = expand("") + let date = trim(system("date -d @" . epoch)) + echo date +endfunction + +function GetEpochDate() + normal! `y + let date = trim(system("date -d " . trim(shellescape(@@)) . ' "+%s"')) + echo date +endfunction + +nnoremap e :call GetHumanReadableDate() +xnoremap e :call GetEpochDate()