From 678c3b8680574eaec1834de0449fa34de6305eb7 Mon Sep 17 00:00:00 2001 From: fretep Date: Sun, 1 Oct 2017 12:07:07 +1100 Subject: [PATCH] Bug fix in todo#todo#GetDateRegexForPastDates For dates in October. --- syntax/todo.vim | 8 +++++++- tests/todo.vader | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/syntax/todo.vim b/syntax/todo.vim index 8d482bf..aeb0e70 100644 --- a/syntax/todo.vim +++ b/syntax/todo.vim @@ -128,7 +128,9 @@ function! todo#GetDateRegexForPastDates(...) " PART 4: All months to the end of the previous month " i.e. for a date of 2017-09-07, "2017-(0[1-8])-\d{2}" - " for 2017-11-30: "2017-(0\d|1[0-1])-\d{2}" + " for 2017-10-01: "2017-(0[0-9])-\d{2}" + " for 2017-11-30: "2017-(0\d|1[0-0])-\d{2}" + " for 2017-12-30: "2017-(0\d|1[0-1])-\d{2}" " for 2017-01-20: skip " This only applies if the reference date is not in January if l:month > 1 @@ -137,6 +139,10 @@ function! todo#GetDateRegexForPastDates(...) let l:overdueRex = l:overdueRex . '\d|1' endif let l:y = strpart(printf('%02d', l:month), 1, 1) " Second digit of the month + if l:month == 10 + " When the month is 10, y = 0, and y - 1 = -1 = bad, deal with it. + let l:y = 10 + endif let l:overdueRex = l:overdueRex . '[0-' . (l:y - 1) . '])\-\d{2})|' endif diff --git a/tests/todo.vader b/tests/todo.vader index 42fd9e5..8daa68c 100644 --- a/tests/todo.vader +++ b/tests/todo.vader @@ -423,7 +423,8 @@ Execute (Log generated RegExp): Execute (Current date should not match): Assert strftime("%Y-%m-%d") !~ b:rex -" Incorrectly matching current date, some breakpoints that previously were found to be an issue +" Incorrectly matching current date, some breakpoints that previously were found +" to be an issue Before: let b:rex = todo#GetDateRegexForPastDates(2017,09,20) Execute (Log generated RegExp): @@ -440,6 +441,14 @@ Execute (2017-09-29 should match with reference 2017-09-30): Assert '2017-09-29' =~ b:rex Execute (2017-09-30 should NOT match with reference 2017-09-30): Assert '2017-09-30' !~ b:rex +Before: + let b:rex = todo#GetDateRegexForPastDates(2017,10,01) +Execute (Log generated RegExp): + Log b:rex +Execute (2017-09-30 should match with reference 2017-10-01): + Assert '2017-09-30' =~ b:rex +Execute (2017-10-01 should NOT match with reference 2017-10-01): + Assert '2017-10-01' !~ b:rex " file: autoload/todo.vim {{{1