Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/timezone_config #180

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions lingua_franca/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,19 @@ def _call_localized_function(func, *args, **kwargs):

# Check if we need to add timezone awareness to any datetime object
if config.inject_timezones:
for k, v in kwargs.items():
if isinstance(v, datetime) and v.tzinfo is None:
kwargs[k] = to_local(v)
for idx, v in enumerate(args):
if isinstance(v, datetime) and v.tzinfo is None:
args = args[:idx] + (to_local(v),) + args[idx + 1:]
for name_of_the_keyword_argument, \
value_of_the_keyword_argument in kwargs.items():
if isinstance(value_of_the_keyword_argument, datetime) \
and value_of_the_keyword_argument.tzinfo is None:
kwargs[name_of_the_keyword_argument] = to_local(
value_of_the_keyword_argument)
for index_of_the_argument, value_of_the_argument in \
enumerate(args):
if isinstance(value_of_the_argument, datetime) \
and value_of_the_argument.tzinfo is None:
args = args[:index_of_the_argument] + \
(to_local(value_of_the_argument),) + \
args[index_of_the_argument + 1:]
JarbasAl marked this conversation as resolved.
Show resolved Hide resolved

# Check if we're passing a lang as a kwarg
if 'lang' in kwargs.keys():
Expand Down