From 39e5e1913f432136b8746d64e37494eefa1f07c8 Mon Sep 17 00:00:00 2001 From: jdhao Date: Thu, 2 Dec 2021 22:06:40 +0800 Subject: Add command :Datetime to show current time or translate a Unix timestamp --- autoload/utils.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'autoload/utils.vim') diff --git a/autoload/utils.vim b/autoload/utils.vim index 8486773..d1933a2 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -145,8 +145,12 @@ function! utils#Get_titlestr() abort return l:title_str endfunction -" Output current time in ISO format. -function! utils#iso_time() abort +" 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) + endif + return strftime('%Y-%m-%d %H:%M:%S%z') endfunction -- cgit v1.2.3