aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/put_date.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-16 19:45:40 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-16 19:49:13 +1200
commitd03a9d7b3f724706775c793df7b6b627ea4ef60a (patch)
treea4a1d06b41dd8475622b43434968d7daaaa67d04 /vim/autoload/put_date.vim
parentDocument choice of format for PutDate() (diff)
downloaddotfiles-d03a9d7b3f724706775c793df7b6b627ea4ef60a.tar.gz
dotfiles-d03a9d7b3f724706775c793df7b6b627ea4ef60a.zip
Consolidate utc.vim and put_date.vim into latter
Diffstat (limited to 'vim/autoload/put_date.vim')
-rw-r--r--vim/autoload/put_date.vim19
1 files changed, 19 insertions, 0 deletions
diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim
new file mode 100644
index 00000000..2b618632
--- /dev/null
+++ b/vim/autoload/put_date.vim
@@ -0,0 +1,19 @@
+let s:rfc_2822 = '%a, %d %b %Y %T %z'
+
+function! put_date#(line, bang, ...) abort
+ let line = a:line
+ let utc = a:bang ==# '!'
+ let format = a:0
+ \ ? substitute(a:1, '\a', '%&', 'g')
+ \ : s:rfc_2822
+ if utc
+ if exists('$TZ')
+ let tz = $TZ
+ endif
+ let $TZ = 'UTC'
+ endif
+ execute line.'put =strftime(format)'
+ if exists('tz')
+ let $TZ = tz
+ endif
+endfunction