File tree 1 file changed +16
-0
lines changed
schema_automator/generalizers
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -680,6 +680,22 @@ def get_db(db_id: str) -> Optional[str]:
680
680
return parts [0 ]
681
681
682
682
683
+ def is_date (string , fuzzy = False ):
684
+ """
685
+ Return whether the string can be interpreted as a date.
686
+
687
+ :param string: str, string to check for date
688
+ :param fuzzy: bool, ignore unknown tokens in string if True
689
+ """
690
+ try :
691
+ parse (string , fuzzy = fuzzy )
692
+ return True
693
+ except Exception :
694
+ # https://stackoverflow.com/questions/4990718/how-can-i-write-a-try-except-block-that-catches-all-exceptions
695
+ # we don't know all the different parse exceptions, we assume any error means this is a date
696
+ return False
697
+
698
+
683
699
def is_date_or_datetime (string , fuzzy = False ):
684
700
"""
685
701
Return whether the string can be interpreted as a date or datetime.
You can’t perform that action at this time.
0 commit comments