Add syntax for now+seconds, now-seconds when parsing units.
This helps a lot when it comes to querying for atom feeds. You can request the last X hours of items instead of picking some limit that you hope is high enough for the highs and wastes data during the lows. You want created=now-86400..now for one day.
This commit is contained in:
		
							parent
							
								
									f8b1cd9178
								
							
						
					
					
						commit
						df5870502a
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		|  | @ -347,13 +347,20 @@ def parse_unit_string(s) -> typing.Union[int, float, None]: | ||||||
|     if ':' in s: |     if ':' in s: | ||||||
|         return hms.hms_to_seconds(s) |         return hms.hms_to_seconds(s) | ||||||
| 
 | 
 | ||||||
|     elif all(c in '0123456789' for c in s): |     if all(c in '0123456789' for c in s): | ||||||
|         return int(s) |         return int(s) | ||||||
| 
 | 
 | ||||||
|     elif all(c in '0123456789.' for c in s): |     if all(c in '0123456789.' for c in s): | ||||||
|         return float(s) |         return float(s) | ||||||
| 
 | 
 | ||||||
|     else: |     if s == 'now': | ||||||
|  |         return now().timestamp() | ||||||
|  | 
 | ||||||
|  |     nowdelta = re.search(r'now((?:\+|-)\d+(?:\.\d*)?)', s) | ||||||
|  |     if nowdelta: | ||||||
|  |         nowdelta = nowdelta.group(1) | ||||||
|  |         return now().timestamp() + float(nowdelta) | ||||||
|  | 
 | ||||||
|     return bytestring.parsebytes(s) |     return bytestring.parsebytes(s) | ||||||
| 
 | 
 | ||||||
| def read_filebytes( | def read_filebytes( | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue