aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
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
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')
-rw-r--r--vim/autoload/put_date.vim19
-rw-r--r--vim/autoload/utc.vim4
2 files changed, 19 insertions, 4 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
diff --git a/vim/autoload/utc.vim b/vim/autoload/utc.vim
deleted file mode 100644
index 1a464342..00000000
--- a/vim/autoload/utc.vim
+++ /dev/null
@@ -1,4 +0,0 @@
-function! utc#(command) abort
- let tz = expand('$TZ')
- let $TZ = 'UTC' | execute a:command | let $TZ = tz
-endfunction