From 17d2e3ab3ec6daa7e58902f17a68b0d92e6c374f Mon Sep 17 00:00:00 2001 From: jdhao Date: Sat, 21 Oct 2023 00:52:25 +0200 Subject: [PATCH] Deal with other variant of unix timestamp --- autoload/utils.vim | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/autoload/utils.vim b/autoload/utils.vim index 9b4bb90..a004bd5 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -128,11 +128,22 @@ endfunction " Output current time or unix timestamp in human-readable format. function! utils#iso_time(timestamp) abort - if a:timestamp - return strftime('%Y-%m-%d %H:%M:%S%z', a:timestamp) + " Get current datetime + if !a:timestamp + return strftime('%Y-%m-%d %H:%M:%S%z') endif - return strftime('%Y-%m-%d %H:%M:%S%z') + " this timestamp in expressed in milliseconds + if len(a:timestamp) == 13 + let l:timestamp = a:timestamp[:-4] + " this timestamp in expressed in microseconds + elseif len(a:timestamp) == 16 + let l:timestamp = a:timestamp[:-7] + else + let l:timestamp = a:timestamp + endif + return strftime('%Y-%m-%d %H:%M:%S%z', l:timestamp) + endfunction " Check if we are inside a Git repo.