aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/html/timestamp.vim
blob: 1b3ea830d78efcac685ea14f0dac763b731b4002 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function! html#timestamp#Update() abort
  if !&modified
    return
  endif
  let l:cv = winsaveview()
  call cursor(1,1)
  let l:li = search('\C^\s*<em>Last updated: .\+</em>$', 'n')
  if l:li
    let l:date = substitute(system('date -u'), '\C\n$', '', '')
    let l:line = getline(l:li)
    call setline(l:li, substitute(l:line, '\C\S.*',
          \ '<em>Last updated: '.l:date.'</em>', ''))
  endif
  call winrestview(l:cv)
endfunction