journal: require consistent separators in a Y/M/D date
Date separators can be /, - or . but only one kind should be used in each date. Eg we now reject 2014-8/1.
This commit is contained in:
		
							parent
							
								
									3e27f4fb8b
								
							
						
					
					
						commit
						c485017ca6
					
				| @ -431,6 +431,8 @@ datep = do | |||||||
|   -- XXX reported error position is not too good |   -- XXX reported error position is not too good | ||||||
|   -- pos <- getPosition |   -- pos <- getPosition | ||||||
|   datestr <- many1 $ choice' [digit, datesepchar] |   datestr <- many1 $ choice' [digit, datesepchar] | ||||||
|  |   let sepchars = nub $ sort $ filter (`elem` datesepchars) datestr | ||||||
|  |   when (length sepchars /= 1) $ fail $ "bad date, different separators used: " ++ datestr | ||||||
|   let dateparts = wordsBy (`elem` datesepchars) datestr |   let dateparts = wordsBy (`elem` datesepchars) datestr | ||||||
|   currentyear <- getYear |   currentyear <- getYear | ||||||
|   [y,m,d] <- case (dateparts,currentyear) of |   [y,m,d] <- case (dateparts,currentyear) of | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user