smart dates: make "this" optional
This commit is contained in:
		
							parent
							
								
									415c48d855
								
							
						
					
					
						commit
						fdc13f6f43
					
				@ -236,7 +236,7 @@ Assumes any text in the parse stream has been lowercased.
 | 
				
			|||||||
smartdate :: GenParser Char st SmartDate
 | 
					smartdate :: GenParser Char st SmartDate
 | 
				
			||||||
smartdate = do
 | 
					smartdate = do
 | 
				
			||||||
  let dateparsers = [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow,
 | 
					  let dateparsers = [yyyymmdd, ymd, ym, md, y, d, month, mon, today, yesterday, tomorrow,
 | 
				
			||||||
                     lastthisnextthing
 | 
					                     lastthisnextthing, thing
 | 
				
			||||||
                    ]
 | 
					                    ]
 | 
				
			||||||
  (y,m,d) <- choice $ map try dateparsers
 | 
					  (y,m,d) <- choice $ map try dateparsers
 | 
				
			||||||
  return $ (y,m,d)
 | 
					  return $ (y,m,d)
 | 
				
			||||||
@ -339,6 +339,17 @@ lastthisnextthing = do
 | 
				
			|||||||
            
 | 
					            
 | 
				
			||||||
  return ("",r,p)
 | 
					  return ("",r,p)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					thing :: GenParser Char st SmartDate
 | 
				
			||||||
 | 
					thing = do
 | 
				
			||||||
 | 
					  p <- choice $ [
 | 
				
			||||||
 | 
					        string "day"
 | 
				
			||||||
 | 
					       ,string "week"
 | 
				
			||||||
 | 
					       ,string "month"
 | 
				
			||||||
 | 
					       ,string "quarter"
 | 
				
			||||||
 | 
					       ,string "year"
 | 
				
			||||||
 | 
					      ]
 | 
				
			||||||
 | 
					  return ("","this",p)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
periodexpr :: Day -> GenParser Char st (Interval, DateSpan)
 | 
					periodexpr :: Day -> GenParser Char st (Interval, DateSpan)
 | 
				
			||||||
periodexpr rdate = choice $ map try [
 | 
					periodexpr rdate = choice $ map try [
 | 
				
			||||||
                    intervalanddateperiodexpr rdate,
 | 
					                    intervalanddateperiodexpr rdate,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user