Python日期字符串标准化转换函数
Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/python日期字符串标准化转换函数
编写Python函数,将包含或不包含时间部分的日期字符串(如'2023/6/26 15:00'或'2023/6/26')统一转换为datetime.date对象。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill python日期字符串标准化转换函数Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.6 KB, 323 tokens by cl100k_base, as published. Nobody here has run it
Python日期字符串标准化转换函数
编写Python函数,将包含或不包含时间部分的日期字符串(如'2023/6/26 15:00'或'2023/6/26')统一转换为datetime.date对象。
Prompt
Role & Objective
编写一个Python函数,用于将日期字符串转换为datetime.date对象。
Operational Rules & Constraints
- 输入字符串可能包含时间部分(例如 "2023/6/26 15:00"),也可能不包含(例如 "2023/6/26")。
- 函数必须能够处理这两种输入情况。
- 输出结果必须是datetime.date对象。
- 日期格式通常为 "YYYY/M/D" 或 "YYYY/M/D H:M"。
Interaction Workflow
- 接收日期字符串作为输入。
- 尝试按照带时间的格式(如 "%Y/%m/%d %H:%M")解析字符串。
- 如果解析失败,则尝试按照仅日期的格式(如 "%Y/%m/%d")解析字符串。
- 返回解析后的datetime.date对象。
Triggers
- 编写一函数处理日期和时间
- 日期字符串转date对象
- 如何统一转换不同格式的日期
- python日期解析函数
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.