Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Python: Bug: TimePlugin timeZoneOffset and timeZoneName always return an empty string

Open Beginner friendly
#14,583 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@jeevan1098 is already working on this.

Since Oct 15, 2026.

  • #14604 by @jeevan1098 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai

Research direction

The bug is in python/semantic_kernel/core_plugins/time_plugin.py, in time_zone_offset and time_zone_name, which call datetime.datetime.now() without a timezone and so get an empty %z and %Z. Read the existing unit tests for TimePlugin, where test_mock_now patches now with a UTC-aware value, and reproduce with the snippet in the issue. Done when both functions return the local offset and zone name for a naive-clock call, and a test covers that path without the aware-UTC mock.

Written by the indexing model from the issue text.

Description

python triage

Describe the bug

TimePlugin.timeZoneOffset and TimePlugin.timeZoneName always return an empty string.

Where

python/semantic_kernel/core_plugins/time_plugin.py:

@kernel_function(description="Get the current time zone offset", name="timeZoneOffset")
def time_zone_offset(self) -> str:
    """... {{time.timeZoneOffset}} => -08:00"""
    now = datetime.datetime.now()
    return now.strftime("%z")

@kernel_function(description="Get the current time zone name", name="timeZoneName")
def time_zone_name(self) -> str:
    """... {{time.timeZoneName}} => PST"""
    now = datetime.datetime.now()
    return now.strftime("%Z")

datetime.datetime.now() without a tz argument returns a naive datetime. For a naive datetime strftime("%z") and strftime("%Z") return "".

The existing unit tests do not catch this because they patch datetime.datetime.now to return a timezone-aware UTC value (test_mock_now), which never happens in real use.

To reproduce

Checked on current main (1b1f64b98), Python 3.13, Windows, local zone US Eastern.

import datetime
from semantic_kernel.core_plugins.time_plugin import TimePlugin

t = TimePlugin()
print(repr(t.time_zone_offset()), repr(t.time_zone_name()))
now = datetime.datetime.now().astimezone()
print(repr(now.strftime("%z")), repr(now.strftime("%Z")))

Actual:

'' ''
'-0400' 'Eastern Daylight Time'

A prompt template such as Time zone: {{time.timeZoneName}} ({{time.timeZoneOffset}}) renders as Time zone: ().

Expected

Both functions return the local zone offset and name. Using datetime.datetime.now().astimezone() gives an aware datetime in the local zone, so %z and %Z are filled.

I have a fix with tests ready and will open a PR for this.

Platform

  • Language: Python
  • Source: main branch of the repository (1b1f64b98)
Dominant language
C#
Stars
28.6k
Forks
4.8k
Avg merge
2d 7h
Merged PRs (30d)
20

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/semantic-kernel

All issues in microsoft/semantic-kernel

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.