File tree Expand file tree Collapse file tree
src/firebase_functions/private Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ def second_timestamp_conversion(time: str) -> _dt.datetime:
371371
372372class PrecisionTimestamp (_enum .Enum ):
373373 """
374- The status of a token .
374+ Timestamp precision levels supported by Firebase event timestamp parsing .
375375 """
376376
377377 NANOSECONDS = "NANOSECONDS"
@@ -385,15 +385,13 @@ def __str__(self) -> str:
385385
386386
387387def get_precision_timestamp (time : str ) -> PrecisionTimestamp :
388- """Return a bool which indicates if the timestamp is in nanoseconds """
388+ """Return the precision used by a Firebase event timestamp. """
389389 if "." not in time :
390390 return PrecisionTimestamp .SECONDS
391391
392392 _ , s_fraction = time .split ("." , 1 )
393- fraction_match = _re .match (r"\d+" , s_fraction )
394- if fraction_match is None :
395- raise ValueError ("Invalid timestamp" )
396-
393+ if not (fraction_match := _re .match (r"\d+" , s_fraction )):
394+ raise ValueError (f"Invalid timestamp format: { time } " )
397395 s_fraction = fraction_match .group ()
398396
399397 # If the fraction is more than 6 digits long, it's a nanosecond timestamp
You can’t perform that action at this time.
0 commit comments