From d1f00706bff58b863b0a1c5bf4adf39d36049d4c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 11 Nov 2022 09:54:35 +0100 Subject: Merging upstream version 10.0.1. Signed-off-by: Daniel Baumann --- sqlglot/time.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'sqlglot/time.py') diff --git a/sqlglot/time.py b/sqlglot/time.py index 729b50d..97726b3 100644 --- a/sqlglot/time.py +++ b/sqlglot/time.py @@ -1,9 +1,13 @@ -# the generic time format is based on python time.strftime +import typing as t + +# The generic time format is based on python time.strftime. # https://docs.python.org/3/library/time.html#time.strftime from sqlglot.trie import in_trie, new_trie -def format_time(string, mapping, trie=None): +def format_time( + string: str, mapping: t.Dict[str, str], trie: t.Optional[t.Dict] = None +) -> t.Optional[str]: """ Converts a time string given a mapping. @@ -11,11 +15,16 @@ def format_time(string, mapping, trie=None): >>> format_time("%Y", {"%Y": "YYYY"}) 'YYYY' - mapping: Dictionary of time format to target time format - trie: Optional trie, can be passed in for performance + Args: + mapping: dictionary of time format to target time format. + trie: optional trie, can be passed in for performance. + + Returns: + The converted time string. """ if not string: return None + start = 0 end = 1 size = len(string) -- cgit v1.2.3