aboutsummaryrefslogtreecommitdiff
path: root/autoload/utils.vim
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2023-10-21 00:52:25 +0200
committerjdhao <jdhao@hotmail.com>2023-10-21 00:53:15 +0200
commit17d2e3ab3ec6daa7e58902f17a68b0d92e6c374f (patch)
tree7201620c3189098132a56e1312e3dcb594ac42a7 /autoload/utils.vim
parent2c9948300d3bce4c825ca0fbc217d8e5f671e1b7 (diff)
Deal with other variant of unix timestamp
Diffstat (limited to 'autoload/utils.vim')
-rw-r--r--autoload/utils.vim17
1 files 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.