MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / format_datetime

Function format_datetime

src/core/utils.py:144–157  ·  view source on GitHub ↗

格式化日期时间 Args: dt: 日期时间对象,如果为 None 则使用当前时间 fmt: 格式字符串 Returns: 格式化后的字符串

(dt: Optional[datetime] = None, fmt: str = "%Y-%m-%d %H:%M:%S")

Source from the content-addressed store, hash-verified

142
143
144def format_datetime(dt: Optional[datetime] = None, fmt: str = "%Y-%m-%d %H:%M:%S") -> str:
145 """
146 格式化日期时间
147
148 Args:
149 dt: 日期时间对象,如果为 None 则使用当前时间
150 fmt: 格式字符串
151
152 Returns:
153 格式化后的字符串
154 """
155 if dt is None:
156 dt = datetime.now()
157 return dt.strftime(fmt)
158
159
160def parse_datetime(dt_str: str, fmt: str = "%Y-%m-%d %H:%M:%S") -> Optional[datetime]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected