1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Deal with other variant of unix timestamp

This commit is contained in:
jdhao 2023-10-21 00:52:25 +02:00
parent 2c9948300d
commit 17d2e3ab3e

View File

@ -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.