aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-10 10:04:59 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-10 10:04:59 +1200
commite894be29ab171ea96c55c149c6720cb7d6123df2 (patch)
treefcff5370386f6cdc7ee29d540198a32a26680574
parentArrange abbreviations in columns (diff)
downloaddotfiles-e894be29ab171ea96c55c149c6720cb7d6123df2.tar.gz
dotfiles-e894be29ab171ea96c55c149c6720cb7d6123df2.zip
Use strftime() for date printing
-rw-r--r--vim/vimrc21
1 files changed, 17 insertions, 4 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 949c1f7b..57c685f9 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1171,12 +1171,25 @@ nnoremap <Leader>C
xnoremap <Leader>C
\ :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>gv
-" Leader,d inserts the local date (POSIX date)
+" Set up a quick command-function pair to run a command with the UTC timezone,
+" in this case, for my date-printing mappings. Is there a nicer way to do
+" this? I couldn't find one.
+"
+function! UTC(command) abort
+ let tz = expand('$TZ')
+ let $TZ = 'UTC'
+ execute a:command
+ let $TZ = tz
+endfunction
+command -complete=command -nargs=1 UTC
+ \ call UTC(<q-args>)
+
+" Leader,d inserts the local date (RFC 2822)
nnoremap <Leader>d
- \ :read !date<CR>
-" Leader,D inserts the UTC date (POSIX date)
+ \ :<C-U>put=strftime('%a, %d %b %Y %T %z')<CR>
+" Leader,D inserts the UTC date (RFC 2822)
nnoremap <Leader>D
- \ :read !date -u<CR>
+ \ :<C-U>UTC put=strftime('%a, %d %b %Y %T %z')<CR>
" Leader,e forces a buffer to be editable
nnoremap <Leader>e