UWSCで西暦を和暦に変換

kt1516

2020年02月15日 10:04



UWSCで西暦を和暦に変換するプログラムです。↓

//西暦を和暦に変換.uws
GETTIME()
date = G_TIME_YY + "/" + G_TIME_MM + "/" + G_TIME_DD
PRINT WesternCalendarToJapaneseCalendar(date)

//西暦から和暦に変換する関数
FUNCTION WesternCalendarToJapaneseCalendar(date)
japanese_calendar = CreateOleObj("System.Globalization.JapaneseCalendar")
era_num = japanese_calendar.GetEra(date)

SELECT era_num
CASE 1
era = "明治"
CASE 2
era = "大正"
CASE 3
era = "昭和"
CASE 4
era = "平成"
CASE 5
era = "令和"
SELEND

year = japanese_calendar.GetYear(date)
month = japanese_calendar.GetMonth(date)
day = japanese_calendar.GetDayOfMonth(date)
RESULT = era + year + "年" + month + "月" + day + "日"
FEND

参考
JapaneseCalendar クラス

関連記事