my.time.tz: implement different policies for localizing
This commit is contained in:
parent
15789a4149
commit
3a9e3e080f
7 changed files with 93 additions and 16 deletions
|
@ -2,8 +2,12 @@
|
|||
Timezone data provider
|
||||
'''
|
||||
from datetime import datetime
|
||||
from ...core.common import tzdatetime
|
||||
|
||||
def localize(dt: datetime) -> datetime:
|
||||
# For now, it's user's reponsibility to check that it actually managed to localize
|
||||
# todo hmm, kwargs isn't mypy friendly.. but specifying types would require duplicating default args. uhoh
|
||||
def localize(dt: datetime, **kwargs) -> tzdatetime:
|
||||
# todo document patterns for combining multiple data sources
|
||||
# e.g. see https://github.com/karlicoss/HPI/issues/89#issuecomment-716495136
|
||||
from . import via_location as L
|
||||
return L.localize(dt)
|
||||
from .common import localize_with_policy
|
||||
return localize_with_policy(L.localize, dt, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue