def convert_year_to_wareki(year):
wareki_start_year = {
'Meiji': 1868, 'Taisho': 1912, 'Showa': 1926, 'Heisei': 1989, 'Reiwa': 2019
}
if year < wareki_start_year['Taisho']:
return f"(Meiji{year - wareki_start_year['Meiji'] + 1}Jahr)"
elif year == wareki_start_year['Taisho']:
return f"(Meiji{year - wareki_start_year['Meiji'] + 1}Jahr/Taisho{year - wareki_start_year['Taisho'] + 1}Jahr)"
elif year < wareki_start_year['Showa']:
return f"(Taisho{year - wareki_start_year['Taisho'] + 1}Jahr)"
elif year == wareki_start_year['Showa']:
return f"(Taisho{year - wareki_start_year['Taisho'] + 1}Jahr/Showa{year - wareki_start_year['Showa'] + 1}Jahr)"
elif year < wareki_start_year['Heisei']:
return f"(Showa{year - wareki_start_year['Showa'] + 1}Jahr)"
elif year == wareki_start_year['Heisei']:
return f"(Showa{year - wareki_start_year['Showa'] + 1}Jahr/Heisei{year - wareki_start_year['Heisei'] + 1}Jahr)"
elif year < wareki_start_year['Reiwa']:
return f"(Heisei{year - wareki_start_year['Heisei'] + 1}Jahr)"
elif year == wareki_start_year['Reiwa']:
return f"(Heisei{year - wareki_start_year['Heisei'] + 1}Jahr/Reiwa{year - wareki_start_year['Reiwa'] + 1}Jahr)"
else:
return f"(Reiwa{year - wareki_start_year['Reiwa'] + 1}Jahr)"
year2Wareki(year){
let wYear = ''
let gen = ''
if(year > 2018){
wYear = year-2018
gen = 'Reiwa'
}else if(year > 1988){
wYear= year-1988
gen = 'Heisei'
}else if(year > 1925){
wYear = year-1925
gen = 'Showa'
}else if(year > 1911){
wYear = year-1911
gen = 'Taisho'
}else if(year > 1867){
wYear = year-1867
gen = 'Meiji'
}
if(wYear === 1) wYear = 'Ehemalige'
return gen !== '' ? gen + wYear + 'Jahr' : false
},
def convert_to_wareki(d: datetime.date) -> str:
dt_native = datetime.datetime.combine(d, datetime.time())
return strjpftime(dt_native, f"{d.year}Jahr(%O%EJahr) {d.month}Mond{d.day}Tag")
2020(2020)1. Januar
Recommended Posts