aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/put_date.vim
blob: 2b618632e8faa5f5612d78457c8c266b230214f5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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