From 53c5943581293194e41d6328cd555509828b9750 Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:22:09 -0500 Subject: [PATCH 1/3] fix: TimePlugin timeZoneOffset/timeZoneName return actual values --- python/semantic_kernel/core_plugins/time_plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/semantic_kernel/core_plugins/time_plugin.py b/python/semantic_kernel/core_plugins/time_plugin.py index 1b8444961644..ef2fe2972ead 100644 --- a/python/semantic_kernel/core_plugins/time_plugin.py +++ b/python/semantic_kernel/core_plugins/time_plugin.py @@ -228,7 +228,7 @@ def time_zone_offset(self) -> str: Example: {{time.timeZoneOffset}} => -08:00 """ - now = datetime.datetime.now() + now = datetime.datetime.now().astimezone() return now.strftime("%z") @kernel_function(description="Get the current time zone name", name="timeZoneName") @@ -238,5 +238,5 @@ def time_zone_name(self) -> str: Example: {{time.timeZoneName}} => PST """ - now = datetime.datetime.now() + now = datetime.datetime.now().astimezone() return now.strftime("%Z") From bac1ee2e1fc94c000d33a5cd810af731e0cf02a0 Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:22:29 -0500 Subject: [PATCH 2/3] test: update TimePlugin tests for timeZoneOffset/timeZoneName fix --- .../unit/core_plugins/test_time_plugin.py | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/python/tests/unit/core_plugins/test_time_plugin.py b/python/tests/unit/core_plugins/test_time_plugin.py index 60fdec31f12c..fbef28777fb1 100644 --- a/python/tests/unit/core_plugins/test_time_plugin.py +++ b/python/tests/unit/core_plugins/test_time_plugin.py @@ -175,7 +175,9 @@ def test_time_zone_offset(): with mock.patch("datetime.datetime", wraps=datetime.datetime) as dt: dt.now.return_value = test_mock_now - assert plugin.time_zone_offset() == "+0000" + # The plugin reports the local zone, so the mocked UTC instant is + # converted to local time before formatting. + assert plugin.time_zone_offset() == test_mock_now.astimezone().strftime("%z") def test_time_zone_name(): @@ -183,4 +185,28 @@ def test_time_zone_name(): with mock.patch("datetime.datetime", wraps=datetime.datetime) as dt: dt.now.return_value = test_mock_now - assert plugin.time_zone_name() == "UTC" + # The plugin reports the local zone, so the mocked UTC instant is + # converted to local time before formatting. + assert plugin.time_zone_name() == test_mock_now.astimezone().strftime("%Z") + + +def test_time_zone_offset_without_mock(): + # Regression test: without mocking datetime.now to an aware value, the + # offset must still be the local zone offset, not an empty string. + plugin = TimePlugin() + + expected = datetime.datetime.now().astimezone().strftime("%z") + result = plugin.time_zone_offset() + assert result != "" + assert result == expected + + +def test_time_zone_name_without_mock(): + # Regression test: without mocking datetime.now to an aware value, the + # zone name must still be the local zone name, not an empty string. + plugin = TimePlugin() + + expected = datetime.datetime.now().astimezone().strftime("%Z") + result = plugin.time_zone_name() + assert result != "" + assert result == expected From 10eb9ff289516cf195447d98c02220a554b5079f Mon Sep 17 00:00:00 2001 From: Jeevan Babu Gotru <114808955+jeevan1098@users.noreply.github.com> Date: Fri, 16 Oct 2026 08:25:52 -0500 Subject: [PATCH 3/3] Fix time_zone_offset docstring example to match %z format --- python/semantic_kernel/core_plugins/time_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/semantic_kernel/core_plugins/time_plugin.py b/python/semantic_kernel/core_plugins/time_plugin.py index ef2fe2972ead..c4effc470d44 100644 --- a/python/semantic_kernel/core_plugins/time_plugin.py +++ b/python/semantic_kernel/core_plugins/time_plugin.py @@ -226,7 +226,7 @@ def time_zone_offset(self) -> str: """Get the current time zone offset. Example: - {{time.timeZoneOffset}} => -08:00 + {{time.timeZoneOffset}} => -0800 """ now = datetime.datetime.now().astimezone() return now.strftime("%z")