From e894be29ab171ea96c55c149c6720cb7d6123df2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 10 Jun 2019 10:04:59 +1200 Subject: Use strftime() for date printing --- vim/vimrc | 21 +++++++++++++++++---- 1 file 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 C xnoremap C \ :setlocal cursorcolumn! cursorcolumn?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() + +" Leader,d inserts the local date (RFC 2822) nnoremap d - \ :read !date -" Leader,D inserts the UTC date (POSIX date) + \ :put=strftime('%a, %d %b %Y %T %z') +" Leader,D inserts the UTC date (RFC 2822) nnoremap D - \ :read !date -u + \ :UTC put=strftime('%a, %d %b %Y %T %z') " Leader,e forces a buffer to be editable nnoremap e -- cgit v1.2.3