mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	ruff: Fix DTZ007 datetime.datetime.strptime() without %z.
				
					
				
			Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							b5cad938b8
						
					
				
				
					commit
					3e10ceb022
				
			@@ -30,7 +30,7 @@ for any particular type of object.
 | 
				
			|||||||
import re
 | 
					import re
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
from dataclasses import dataclass
 | 
					from dataclasses import dataclass
 | 
				
			||||||
from datetime import datetime
 | 
					from datetime import datetime, timezone
 | 
				
			||||||
from decimal import Decimal
 | 
					from decimal import Decimal
 | 
				
			||||||
from typing import (
 | 
					from typing import (
 | 
				
			||||||
    Any,
 | 
					    Any,
 | 
				
			||||||
@@ -147,7 +147,10 @@ def check_date(var_name: str, val: object) -> str:
 | 
				
			|||||||
    if not isinstance(val, str):
 | 
					    if not isinstance(val, str):
 | 
				
			||||||
        raise ValidationError(_("{var_name} is not a string").format(var_name=var_name))
 | 
					        raise ValidationError(_("{var_name} is not a string").format(var_name=var_name))
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        if datetime.strptime(val, "%Y-%m-%d").strftime("%Y-%m-%d") != val:
 | 
					        if (
 | 
				
			||||||
 | 
					            datetime.strptime(val, "%Y-%m-%d").replace(tzinfo=timezone.utc).strftime("%Y-%m-%d")
 | 
				
			||||||
 | 
					            != val
 | 
				
			||||||
 | 
					        ):
 | 
				
			||||||
            raise ValidationError(_("{var_name} is not a date").format(var_name=var_name))
 | 
					            raise ValidationError(_("{var_name} is not a date").format(var_name=var_name))
 | 
				
			||||||
    except ValueError:
 | 
					    except ValueError:
 | 
				
			||||||
        raise ValidationError(_("{var_name} is not a date").format(var_name=var_name))
 | 
					        raise ValidationError(_("{var_name} is not a date").format(var_name=var_name))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user