Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#14,583 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@jeevan1098 がすでに取り組んでいます。

2026年10月15日 から。

  • #14604 @jeevan1098 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
80/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
ai

調査の方向性

バグは python/semantic_kernel/core_plugins/time_plugin.py の time_zone_offset と time_zone_name にあります。両関数はタイムゾーンなしで datetime.datetime.now() を呼び出しているため、%z と %Z が空になります。TimePlugin の既存ユニットテストを読んでください。test_mock_now は now を UTC 付きの値でパッチしています。issue のスニペットで再現してください。両関数が、タイムゾーンのない現在時刻での呼び出しに対してローカルのオフセットとゾーン名を返し、その経路を UTC 付きモックを使わずにテストがカバーすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
C#
スター
28.6k
フォーク
4.8k
平均マージ
2日 12時間
マージ済み PR(30日)
22

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/semantic-kernel のほかの issue

microsoft/semantic-kernel の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。