The jpdatetime library extends Python's datetime to support Japanese eras (元号). It allows parsing and formatting dates in Japanese eras like Reiwa (令和), Heisei (平成), and more, including special support for first-year notation (元年).
Description:
This pull request adds support for handling the first year notation (元年) in the jpdatetime class. The changes include modifying the strptime and strftime methods to correctly parse and format dates that fall in the first year of a Japanese era. This enhancement ensures that dates like "令和元年" or "平成元年" are properly interpreted and formatted, improving the overall accuracy and usability of Japanese era date handling.
Key Changes:
Updated strptime to recognize and parse the first year notation ("元年") as year 1 for each respective era.
Enhanced strftime to format the first year of an era as "元年" instead of "1年".
Added relevant test cases to verify correct parsing and formatting of dates containing "元年".
Benefits:
Improves the realism and accuracy of Japanese date representations by properly supporting the culturally significant "元年" notation.
Adds flexibility for users dealing with Japanese historical data or modern documentation that uses the traditional first-year format.
Testing:
Added new unit tests to cover the parsing and formatting of first-year era dates.
All existing unit tests have been run to ensure no regressions occurred due to these changes.
Please review the changes and provide feedback. If there are any questions or suggestions for further improvements, feel free to let me know.
Pull Request: Support for First Year Format (元年)
Description: This pull request adds support for handling the first year notation (元年) in the jpdatetime class. The changes include modifying the strptime and strftime methods to correctly parse and format dates that fall in the first year of a Japanese era. This enhancement ensures that dates like "令和元年" or "平成元年" are properly interpreted and formatted, improving the overall accuracy and usability of Japanese era date handling.
Key Changes:
Updated strptime to recognize and parse the first year notation ("元年") as year 1 for each respective era.
Enhanced strftime to format the first year of an era as "元年" instead of "1年".
Added relevant test cases to verify correct parsing and formatting of dates containing "元年".
Benefits:
Improves the realism and accuracy of Japanese date representations by properly supporting the culturally significant "元年" notation.
Adds flexibility for users dealing with Japanese historical data or modern documentation that uses the traditional first-year format.
Testing:
Added new unit tests to cover the parsing and formatting of first-year era dates.
All existing unit tests have been run to ensure no regressions occurred due to these changes.
Please review the changes and provide feedback. If there are any questions or suggestions for further improvements, feel free to let me know.