### Install jpdatetime from GitHub Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Install the latest version of the jpdatetime library directly from its GitHub repository. ```shell git clone https://github.com/new-village/JapaneseDatetime cd JapaneseDatetime python setup.py install ``` -------------------------------- ### Install jpdatetime via pip Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Install the jpdatetime library using pip for standard Python package management. ```shell python -m pip install jpdatetime ``` -------------------------------- ### Supported Japanese Eras and Examples Source: https://context7.com/new-village/japanesedatetime/llms.txt Lists the range of Japanese eras supported by the library, from Reiki to Reiwa, with examples of formatting dates within these eras. ```APIDOC ## Supported Japanese Eras The library supports eras from Reiki (霊亀, 715 CE) to Reiwa (令和, 2019-present). ```python from jpdatetime import jpdatetime # Modern eras reiwa = jpdatetime(2024, 1, 1) print(reiwa.strftime("%G (%E)")) # Output: 令和06 (Reiwa 06) heisei = jpdatetime(2000, 1, 1) print(heisei.strftime("%G (%E)")) # Output: 平成12 (Heisei 12) showa = jpdatetime(1950, 1, 1) print(showa.strftime("%G (%E)")) # Output: 昭和25 (Shōwa 25) taiso = jpdatetime(1920, 1, 1) print(taisho.strftime("%G (%E)")) # Output: 大正09 (Taishō 09) meiji = jpdatetime(1900, 1, 1) print(meiji.strftime("%G (%E)")) # Output: 明治33 (Meiji 33) # Historical era (earliest supported) reiki = jpdatetime(715, 10, 3) print(reiki.strftime("%G (%E)")) # Output: 霊亀元 (Reiki 01) ``` ``` -------------------------------- ### jpdatetime Library Usage Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Examples demonstrating how to use the jpdatetime library for parsing and formatting dates with Japanese eras. ```APIDOC ## Parsing Japanese Era Dates ### Description Parses Japanese era date strings into Gregorian datetime objects using `jpdatetime.strptime`. ### Method `jpdatetime.strptime(date_string, format_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from jpdatetime import jpdatetime date_string = "平成三〇年十二月二四日" format_string = "%G年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2018-12-24 00:00:00 date_string = "令和元年5月1日" format_string = "%G年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-05-01 00:00:00 date_string = "令1年10月30日" format_string = "%g年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-10-30 00:00:00 date_string = "Heisei 30, April 1" format_string = "%E, %B %d" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2018-04-01 00:00:00 date_string = "R1/05/01" format_string = "%e/%m/%d" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-05-01 00:00:00 ``` ### Response #### Success Response (200) - **date_obj** (datetime) - The parsed datetime object. #### Response Example ``` 2018-12-24 00:00:00 ``` ## Formatting Gregorian Dates to Japanese Era Strings ### Description Formats Gregorian datetime objects into Japanese era formatted strings using `jpdatetime.strftime`. ### Method `date_obj.strftime(format_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from jpdatetime import jpdatetime date = jpdatetime(2024, 10, 30) formatted_date = date.strftime("%G年%m月%d日") print(formatted_date) # Output: "令和06年10月30日" date = jpdatetime(2019, 5, 1) formatted_date = date.strftime("%G年%m月%d日") print(formatted_date) # Output: "令和元年5月1日" date = jpdatetime(2019, 10, 30) formatted_date = date.strftime("%g年%m月%d日") print(formatted_date) # Output: "令1年10月30日" date = jpdatetime(2018, 4, 1) formatted_date = date.strftime("%E, %B %d") print(formatted_date) # Output: "Heisei 30, April 01" date = jpdatetime(2019, 5, 1) formatted_date = date.strftime("%e/%m/%d") print(formatted_date) # Output: "R1/05/01" ``` ### Response #### Success Response (200) - **formatted_date** (string) - The formatted date string in Japanese era format. #### Response Example ``` 令和06年10月30日 ``` ## `strftime()` and `strptime()` Format Codes ### Description Provides a reference for the custom format codes supported by `jpdatetime` for `strftime` and `strptime` methods, in addition to standard Python datetime format codes. ### Method N/A (Reference table) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **Format Codes Table**: A table detailing the meaning and examples of each custom format code. #### Response Example ```markdown | Directive | Meaning | Example | |-----------|----------------------------------------------------------------------------------------------------------|--------------| | `%G` | Full Japanese era name with year. Displays "令和元" for the first year and "平成30" for other years. | 令和元, 平成30 | | `%-G`/`%#G` | Full Japanese era name with year (without zero-padding). Displays non-zero-padded numbers for other years (e.g., "平成6"). | 令和2, 平成6 | | `%g` | Abbreviated Japanese era name (first character) with year. Shows "令01" for the first year and zero-padded numbers for other years (e.g., "平30"). | 令01, 平30 | | `%-g`/`%#g` | Abbreviated Japanese era name with year (without zero-padding). Shows "令1" for the first year and non-zero-padded numbers for other years (e.g., "平30"). | 令1, 平6 | | `%E` | Full English era name with year. Displays "Reiwa 01" for the first year and "Heisei 30" for other years. | Reiwa 01, Heisei 30 | | `%-E`/`%#E` | Full English era name with year (without zero-padding). Displays "Reiwa 1" for the first year and non-zero-padded numbers for other years (e.g., "Heisei 30"). | Reiwa 1, Heisei 30 | | `%e` | Abbreviated English era name (first letter) with year. Shows "R01" for the first year and "H30" for other years. | R01, H30 | | `%-e`/`%#e` | Abbreviated English era name with year (without zero-padding). Shows "R1" for the first year and non-zero-padded numbers for other years (e.g., "H30"). | R1, H30 | ``` **Note**: `%Y`, `%m`, `%d`, `%B`, etc. are standard `datetime` format specifiers. See [Python datetime format codes](https://docs.python.org/3/library/datetime.html#format-codes) for more details. ``` -------------------------------- ### Parse Dates with Kanji Numerals Source: https://context7.com/new-village/japanesedatetime/llms.txt The library automatically converts kanji numerals to Arabic numerals during parsing. This example shows parsing dates with kanji numerals using the %G format code. ```python from jpdatetime import jpdatetime # Parse dates with kanji numerals (0-99 supported) date = jpdatetime.strptime("令和五年十月三十日", "%G年%m月%d日") print(date) # Output: 2023-10-30 00:00:00 # Different kanji numeral formats date = jpdatetime.strptime("平成三〇年四月一日", "%G年%m月%d日") print(date) # Output: 2018-04-01 00:00:00 # Alternative kanji format (二十四 = 24) date = jpdatetime.strptime("大正十五年十二月二十四日", "%G年%m月%d日") print(date) # Output: 1926-12-24 00:00:00 # Kanji zero representation date = jpdatetime.strptime("明治四五年七月二九日", "%G年%m月%d日") print(date) # Output: 1912-07-29 00:00:00 ``` -------------------------------- ### Era Transition Handling Source: https://context7.com/new-village/japanesedatetime/llms.txt Explains and demonstrates how the library correctly handles dates that fall on the transition between Japanese eras, ensuring accurate era assignment. ```APIDOC ## Era Transition Handling Correctly handles dates at era boundaries where the same Gregorian date might belong to different eras. ```python from jpdatetime import jpdatetime # Last day of Heisei (April 30, 2019) last_heisei = jpdatetime(2019, 4, 30) print(last_heisei.strftime("%G年%m月%d日")) # Output: 平成31年04月30日 # First day of Reiwa (May 1, 2019) first_reiwa = jpdatetime(2019, 5, 1) print(first_reiwa.strftime("%G年%m月%d日")) # Output: 令和元年05月01日 # Last day of Showa (January 7, 1989) last_showa = jpdatetime(1989, 1, 7) print(last_showa.strftime("%G年%m月%d日")) # Output: 昭和64年01月07日 # First day of Heisei (January 8, 1989) first_heisei = jpdatetime(1989, 1, 8) print(first_heisei.strftime("%G年%m月%d日")) # Output: 平成元年01月08日 ``` ``` -------------------------------- ### Handle Era Transition Dates Source: https://context7.com/new-village/japanesedatetime/llms.txt This code shows how the library correctly handles dates at era boundaries, ensuring accurate representation for the last day of one era and the first day of the next. ```python from jpdatetime import jpdatetime # Last day of Heisei (April 30, 2019) last_heisei = jpdatetime(2019, 4, 30) print(last_heisei.strftime("%G年%m月%d日")) # Output: 平成31年04月30日 # First day of Reiwa (May 1, 2019) first_reiwa = jpdatetime(2019, 5, 1) print(first_reiwa.strftime("%G年%m月%d日")) # Output: 令和元年05月01日 # Last day of Showa (January 7, 1989) last_showa = jpdatetime(1989, 1, 7) print(last_showa.strftime("%G年%m月%d日")) # Output: 昭和64年01月07日 # First day of Heisei (January 8, 1989) first_heisei = jpdatetime(1989, 1, 8) print(first_heisei.strftime("%G年%m月%d日")) # Output: 平成元年01月08日 ``` -------------------------------- ### Format Modern and Historical Japanese Eras Source: https://context7.com/new-village/japanesedatetime/llms.txt Demonstrates formatting dates into Japanese eras, including modern eras like Reiwa and Heisei, as well as historical eras like Reiki. ```python from jpdatetime import jpdatetime # Modern eras reiwa = jpdatetime(2024, 1, 1) print(reiwa.strftime("%G (%E)")) # Output: 令和06 (Reiwa 06) heisei = jpdatetime(2000, 1, 1) print(heisei.strftime("%G (%E)")) # Output: 平成12 (Heisei 12) showa = jpdatetime(1950, 1, 1) print(showa.strftime("%G (%E)")) # Output: 昭和25 (Shōwa 25) taisho = jpdatetime(1920, 1, 1) print(taisho.strftime("%G (%E)")) # Output: 大正09 (Taishō 09) meiji = jpdatetime(1900, 1, 1) print(meiji.strftime("%G (%E)")) # Output: 明治33 (Meiji 33) # Historical era (earliest supported) reiki = jpdatetime(715, 10, 3) print(reiki.strftime("%G (%E)")) # Output: 霊亀元 (Reiki 01) ``` -------------------------------- ### Kanji Numeral Conversion for Parsing Source: https://context7.com/new-village/japanesedatetime/llms.txt Illustrates how the library automatically parses dates containing Japanese era names and kanji numerals into standard datetime objects. ```APIDOC ## Kanji Numeral Conversion The library automatically converts kanji numerals to Arabic numerals during parsing. ```python from jpdatetime import jpdatetime # Parse dates with kanji numerals (0-99 supported) date = jpdatetime.strptime("令和五年十月三十日", "%G年%m月%d日") print(date) # Output: 2023-10-30 00:00:00 # Different kanji numeral formats date = jpdatetime.strptime("平成三〇年四月一日", "%G年%m月%d日") print(date) # Output: 2018-04-01 00:00:00 # Alternative kanji format (二十四 = 24) date = jpdatetime.strptime("大正十五年十二月二十四日", "%G年%m月%d日") print(date) # Output: 1926-12-24 00:00:00 # Kanji zero representation date = jpdatetime.strptime("明治四五年七月二九日", "%G年%m月%d日") print(date) # Output: 1912-07-29 00:00:00 ``` ``` -------------------------------- ### Parse English Era Date Strings Source: https://context7.com/new-village/japanesedatetime/llms.txt Use strptime with English era names and abbreviations. ```python from jpdatetime import jpdatetime # Parse full English era name date = jpdatetime.strptime("Heisei 30, April 1", "%E, %B %d") print(date) # Output: 2018-04-01 00:00:00 # Parse Reiwa era in English date = jpdatetime.strptime("Reiwa 05, October 30", "%E, %B %d") print(date) # Output: 2023-10-30 00:00:00 # Parse abbreviated English era (single letter) date = jpdatetime.strptime("R1/05/01", "%e/%m/%d") print(date) # Output: 2019-05-01 00:00:00 # Parse Showa era abbreviated date = jpdatetime.strptime("S64/01/07", "%e/%m/%d") print(date) # Output: 1989-01-07 00:00:00 # Parse Meiji era date = jpdatetime.strptime("M45/07/29", "%e/%m/%d") print(date) # Output: 1912-07-29 00:00:00 ``` -------------------------------- ### Japanese Era Formatting Codes Source: https://context7.com/new-village/japanesedatetime/llms.txt Demonstrates the usage of various format codes for displaying Japanese eras in different formats (full name, abbreviated, English, etc.) combined with standard datetime codes. ```APIDOC ## Format Showa era date = jpdatetime(1989, 1, 7) print(date.strftime("%E, %B %d")) # Output: Shōwa 64, January 07 ## Format Codes Reference Complete reference for all Japanese era format codes supported by the library. ```python from jpdatetime import jpdatetime date = jpdatetime(2023, 10, 30) first_year = jpdatetime(2019, 5, 1) # %G - Full Japanese era name with year (zero-padded) print(date.strftime("%G")) # Output: 令和05 print(first_year.strftime("%G")) # Output: 令和元 (uses 元 for first year) # %-G or %#G - Full Japanese era without zero-padding print(date.strftime("%-G")) # Output: 令和5 # %g - Abbreviated Japanese era (first character) with year print(date.strftime("%g")) # Output: 令05 print(date.strftime("%-g")) # Output: 令5 # %E - Full English era name with year print(date.strftime("%E")) # Output: Reiwa 05 print(date.strftime("%-E")) # Output: Reiwa 5 # %e - Abbreviated English era (first letter) with year print(date.strftime("%e")) # Output: R05 print(date.strftime("%-e")) # Output: R5 # Combined with standard datetime format codes print(date.strftime("%G年%m月%d日 %H時%M分")) # Output: 令和05年10月30日 00時00分 print(date.strftime("%e/%m/%d (%Y)")) # Output: R05/10/30 (2023) ``` ``` -------------------------------- ### Format Showa Era Date Source: https://context7.com/new-village/japanesedatetime/llms.txt Use the %E format code to display the full English era name with the year. The %B and %d codes format the month and day. ```python from jpdatetime import jpdatetime date = jpdatetime(1989, 1, 7) print(date.strftime("%E, %B %d")) # Output: Shōwa 64, January 07 ``` -------------------------------- ### Initialize jpdatetime Object Source: https://context7.com/new-village/japanesedatetime/llms.txt The jpdatetime class inherits from standard datetime, allowing for standard attribute access. ```python from jpdatetime import jpdatetime # Create a jpdatetime object (same as standard datetime) date = jpdatetime(2024, 10, 30) print(date) # Output: 2024-10-30 00:00:00 # Access standard datetime attributes print(date.year) # Output: 2024 print(date.month) # Output: 10 print(date.day) # Output: 30 ``` -------------------------------- ### Japanese Era Formatting Codes Source: https://context7.com/new-village/japanesedatetime/llms.txt This section demonstrates various format codes for Japanese eras, including full names, abbreviated names, and zero-padded/non-padded years. ```python from jpdatetime import jpdatetime date = jpdatetime(2023, 10, 30) first_year = jpdatetime(2019, 5, 1) # %G - Full Japanese era name with year (zero-padded) print(date.strftime("%G")) # Output: 令和05 print(first_year.strftime("%G")) # Output: 令和元 (uses 元 for first year) # %-G or %#G - Full Japanese era without zero-padding print(date.strftime("%-G")) # Output: 令和5 # %g - Abbreviated Japanese era (first character) with year print(date.strftime("%g")) # Output: 令05 print(date.strftime("%-g")) # Output: 令5 # %E - Full English era name with year print(date.strftime("%E")) # Output: Reiwa 05 print(date.strftime("%-E")) # Output: Reiwa 5 # %e - Abbreviated English era (first letter) with year print(date.strftime("%e")) # Output: R05 print(date.strftime("%-e")) # Output: R5 # Combined with standard datetime format codes print(date.strftime("%G年%m月%d日 %H時%M分")) # Output: 令和05年10月30日 00時00分 print(date.strftime("%e/%m/%d (%Y)")) # Output: R05/10/30 (2023) ``` -------------------------------- ### Format Dates with English Era Names Source: https://context7.com/new-village/japanesedatetime/llms.txt Use strftime to format dates using English era names for international applications. ```python from jpdatetime import jpdatetime # Format with full English era name date = jpdatetime(2023, 10, 30) print(date.strftime("%E, %B %d")) # Output: Reiwa 05, October 30 # Format without zero-padding print(date.strftime("%-E, %B %d")) # Output: Reiwa 5, October 30 # Format abbreviated English era (single letter) print(date.strftime("%e/%m/%d")) # Output: R05/10/30 print(date.strftime("%-e/%m/%d")) # Output: R5/10/30 # Format Heisei era in English date = jpdatetime(2018, 4, 1) print(date.strftime("%E, %B %d")) # Output: Heisei 30, April 01 print(date.strftime("%e/%m/%d")) # Output: H30/04/01 ``` -------------------------------- ### strptime - Parse Japanese Era Date Strings Source: https://context7.com/new-village/japanesedatetime/llms.txt Parses strings containing Japanese era names into datetime objects, supporting various formats including kanji numerals and first-year notation. ```APIDOC ## strptime(date_string, format) ### Description Parses a string representing a date with a Japanese era into a jpdatetime object. ### Parameters - **date_string** (string) - Required - The date string to parse (e.g., "令和05年10月30日"). - **format** (string) - Required - The format string using custom codes like %G (full era), %g (abbreviated era), %E (English full era), or %e (English abbreviated era). ### Request Example jpdatetime.strptime("令和元年5月1日", "%G年%m月%d日") ### Response - **Result** (jpdatetime object) - A datetime object representing 2019-05-01. ``` -------------------------------- ### Parse Japanese Era Date Strings Source: https://context7.com/new-village/japanesedatetime/llms.txt Use strptime to convert Japanese era strings into datetime objects, supporting kanji, full-width characters, and 元年 notation. ```python from jpdatetime import jpdatetime # Parse full Japanese era name with standard numerals date = jpdatetime.strptime("令和05年10月30日", "%G年%m月%d日") print(date) # Output: 2023-10-30 00:00:00 # Parse with kanji numerals (automatically converted) date = jpdatetime.strptime("平成三〇年十二月二四日", "%G年%m月%d日") print(date) # Output: 2018-12-24 00:00:00 # Parse first year of an era using 元年 notation date = jpdatetime.strptime("令和元年5月1日", "%G年%m月%d日") print(date) # Output: 2019-05-01 00:00:00 # Parse full-width characters (automatically normalized) date = jpdatetime.strptime("令和05年10月30日", "%G年%m月%d日") print(date) # Output: 2023-10-30 00:00:00 # Parse abbreviated Japanese era name date = jpdatetime.strptime("令1年10月30日", "%-g年%m月%d日") print(date) # Output: 2019-10-30 00:00:00 # Parse Heisei era dates date = jpdatetime.strptime("平成30年04月01日", "%G年%m月%d日") print(date) # Output: 2018-04-01 00:00:00 ``` -------------------------------- ### Parse using full English era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Parse date strings with full English era names (e.g., 'Heisei 30') using the '%E' format code in strptime. This supports English representations of Japanese eras. ```python from jpdatetime import jpdatetime # Using English era names date_string = "Heisei 30, April 1" format_string = "%E, %B %d" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2018-04-01 00:00:00 ``` -------------------------------- ### Format Dates with Japanese Era Names Source: https://context7.com/new-village/japanesedatetime/llms.txt Use strftime to format datetime objects into Japanese era strings, supporting zero-padding and 元年 notation. ```python from jpdatetime import jpdatetime # Format with full Japanese era name (zero-padded) date = jpdatetime(2023, 10, 30) print(date.strftime("%G年%m月%d日")) # Output: 令和05年10月30日 # Format without zero-padding using - modifier print(date.strftime("%-G年%m月%d日")) # Output: 令和5年10月30日 # Format first year with 元年 notation date = jpdatetime(2019, 5, 1) print(date.strftime("%G年%m月%d日")) # Output: 令和元年05月01日 # Format abbreviated Japanese era date = jpdatetime(2023, 10, 30) print(date.strftime("%g年%m月%d日")) # Output: 令05年10月30日 print(date.strftime("%-g年%m月%d日")) # Output: 令5年10月30日 # Format different eras date = jpdatetime(2018, 4, 1) # Heisei era print(date.strftime("%G年%m月%d日")) # Output: 平成30年04月01日 date = jpdatetime(1989, 1, 7) # Last day of Showa print(date.strftime("%G年%m月%d日")) # Output: 昭和64年01月07日 ``` -------------------------------- ### Format datetime object for the first year of an era Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Format a datetime object to represent the first year of a Japanese era using strftime. The '%G' format code will correctly render '元年' for the first year. ```python from jpdatetime import jpdatetime # Formatting a datetime object for the first year of an era date = jpdatetime(2019, 5, 1) formatted_date = date.strftime("%G年%m月%d日") print(formatted_date) # Output: "令和元年5月1日" ``` -------------------------------- ### Format using abbreviated English era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Format a datetime object into a string with abbreviated English era names using the '%e' format code in strftime. This produces output like 'R1'. ```python from jpdatetime import jpdatetime date = jpdatetime(2019, 5, 1) formatted_date = date.strftime("%e/%m/%d") print(formatted_date) # Output: "R1/05/01" ``` -------------------------------- ### Format datetime object to Japanese era date string Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Use the strftime method of a jpdatetime object to format it into a Japanese era date string. The format string determines the output's appearance. ```python from jpdatetime import jpdatetime # Formatting a datetime object to a Japanese era date string date = jpdatetime(2024, 10, 30) formatted_date = date.strftime("%G年%m月%d日") print(formatted_date) # Output: "令和06年10月30日" ``` -------------------------------- ### Format using full English era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Format a datetime object into a string with full English era names using the '%E' format code in strftime. This produces output like 'Heisei 30'. ```python from jpdatetime import jpdatetime date = jpdatetime(2018, 4, 1) formatted_date = date.strftime("%E, %B %d") print(formatted_date) # Output: "Heisei 30, April 01" ``` -------------------------------- ### Parse using abbreviated Japanese era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Parse date strings with abbreviated Japanese era names (e.g., '令1') using the '%g' format code in strptime. This handles single-character era abbreviations. ```python from jpdatetime import jpdatetime # Using abbreviated era names date_string = "令1年10月30日" format_string = "%g年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-10-30 00:00:00 ``` -------------------------------- ### strftime - Format Dates with Japanese Era Names Source: https://context7.com/new-village/japanesedatetime/llms.txt Formats a jpdatetime object into a string using Japanese era names, supporting zero-padding and specific era notation. ```APIDOC ## strftime(format) ### Description Formats the jpdatetime object into a string based on the provided format codes. ### Parameters - **format** (string) - Required - The format string. Use %G for full Japanese era, %g for abbreviated Japanese era, %E for full English era, and %e for abbreviated English era. Use '-' prefix for no zero-padding. ### Request Example date = jpdatetime(2023, 10, 30) date.strftime("%G年%m月%d日") ### Response - **Result** (string) - The formatted date string (e.g., "令和05年10月30日"). ``` -------------------------------- ### Format using abbreviated Japanese era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Format a datetime object into a string with abbreviated Japanese era names using the '%g' format code in strftime. This produces output like '令1'. ```python from jpdatetime import jpdatetime date = jpdatetime(2019, 10, 30) formatted_date = date.strftime("%g年%m月%d日") print(formatted_date) # Output: "令1年10月30日" ``` -------------------------------- ### Handle first year of an era during parsing Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Parse date strings representing the first year of a Japanese era (元年) using jpdatetime.strptime. The format string should include '%G' for the era name and year. ```python from jpdatetime import jpdatetime # Handling the first year of an era date_string = "令和元年5月1日" format_string = "%G年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-05-01 00:00:00 ``` -------------------------------- ### Parse using abbreviated English era names Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Parse date strings with abbreviated English era names (e.g., 'R1') using the '%e' format code in strptime. This supports single-letter English era abbreviations. ```python from jpdatetime import jpdatetime # Using abbreviated English era names date_string = "R1/05/01" format_string = "%e/%m/%d" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2019-05-01 00:00:00 ``` -------------------------------- ### Parse Japanese era date string to datetime object Source: https://github.com/new-village/japanesedatetime/blob/main/README.md Use jpdatetime.strptime to convert a Japanese era date string into a Python datetime object. Ensure the format string matches the input date string's structure. ```python from jpdatetime import jpdatetime # Parsing Japanese era date string to a datetime object date_string = "平成三〇年十二月二四日" format_string = "%G年%m月%d日" date_obj = jpdatetime.strptime(date_string, format_string) print(date_obj) # Output: 2018-12-24 00:00:00 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.