Skip to content

Commit

Permalink
Deal with other variant of unix timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhao committed Oct 20, 2023
1 parent 2c99483 commit 17d2e3a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions autoload/utils.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 17d2e3a

Please sign in to comment.