diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-31 01:15:36 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2020-05-31 01:20:33 +1200 |
commit | 598090797c2cb3a4fe945d2eacd3eca42a0cfe5d (patch) | |
tree | 96daceb67ab452bdb98cbc63d78112454c20c370 /autoload | |
download | vim-put-date-598090797c2cb3a4fe945d2eacd3eca42a0cfe5d.tar.gz vim-put-date-598090797c2cb3a4fe945d2eacd3eca42a0cfe5d.zip |
First version from tejr dotfiles v9.12.0v0.1.0
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/put_date.vim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/autoload/put_date.vim b/autoload/put_date.vim new file mode 100644 index 0000000..b0b0b54 --- /dev/null +++ b/autoload/put_date.vim @@ -0,0 +1,24 @@ +" RFC2822 format string for strftime() +let s:rfc_2822 = '%a, %d %b %Y %T %z' + +" Write a date to the buffer, UTC or local, in the specified format, +" defaulting to RFC2822; formats are provided without the leading % signs +" before each letter, like PHP date() +" +function! put_date#(line, utc, format) abort + let line = a:line + let utc = a:utc + let format = strlen(a:format) + \ ? substitute(a:format, '\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 |