blob: b0b0b54836950e981b0ab74194d9a36d935b26b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
|