Created
April 8, 2014 08:40
-
-
Save AndrewVos/10102149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:ConvertToCharClass(cur) | |
if a:cur =~ '[2-9]' | |
return '[0-' . (a:cur-1) . ']' | |
endif | |
return '0' | |
endfunction | |
function! s:MatchNumberBefore(num) | |
let branches = [] | |
let init = '' | |
for i in range(len(a:num)) | |
if a:num[i] =~ '[1-9]' | |
call add(branches, init . s:ConvertToCharClass(a:num[i]) . repeat('\d', len(a:num) - i - 1)) | |
endif | |
let init .= a:num[i] | |
endfor | |
return '\%(' . join(branches, '\|') .'\)' | |
endfunction | |
let s:beforeYear = s:MatchNumberBefore(strftime("%Y")) | |
let s:beforeMonth = s:MatchNumberBefore(strftime("%m")) | |
let s:beforeDay = s:MatchNumberBefore(strftime("%d")) | |
let s:year = strftime("%Y") | |
let s:month = strftime("%m") | |
let s:day = strftime("%d") | |
exec "syntax match TodoDatePast \"\\[\\d\\{2}-\\d\\{2}-" . s:beforeYear . "\\]\"" | |
exec "syntax match TodoDatePast \"\\[\\d\\{2}-" . s:beforeMonth . "-" . s:year . "\\]\"" | |
exec "syntax match TodoDatePast \"\\[" . s:beforeDay . "-" . s:month . "-" . s:year . "\\]\"" | |
highlight link TodoDatePast TodoRed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment