回答編集履歴
1
コード修正
test
CHANGED
@@ -28,33 +28,27 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
def conv
|
31
|
+
def conv(s):
|
32
32
|
|
33
|
-
|
33
|
+
# 年月を抽出
|
34
34
|
|
35
|
-
|
35
|
+
rules = [(r'(\d+)-(\d+)', 0), (r'平成(\d+)年(\d+)月', 1988), (r'昭和(\d+)年(\d+)月', 1925)]
|
36
36
|
|
37
|
-
|
37
|
+
y, m = None, None
|
38
38
|
|
39
|
-
|
39
|
+
for exp, offset in rules:
|
40
40
|
|
41
|
-
|
41
|
+
ret = re.search(exp, s)
|
42
42
|
|
43
|
-
ret
|
43
|
+
if ret:
|
44
44
|
|
45
|
-
|
45
|
+
y = int(ret.group(1)) + offset
|
46
46
|
|
47
|
-
|
47
|
+
m = int(ret.group(2))
|
48
48
|
|
49
|
-
return int(m.group(1))+1925, int(m.group(2))
|
50
|
-
|
51
|
-
re
|
49
|
+
break
|
52
50
|
|
53
51
|
|
54
|
-
|
55
|
-
def conv(s):
|
56
|
-
|
57
|
-
y,m = conv_ym(s)
|
58
52
|
|
59
53
|
s = ''
|
60
54
|
|
@@ -63,8 +57,6 @@
|
|
63
57
|
s = f'{y}年{m}月'
|
64
58
|
|
65
59
|
return s
|
66
|
-
|
67
|
-
|
68
60
|
|
69
61
|
|
70
62
|
|
@@ -82,4 +74,8 @@
|
|
82
74
|
|
83
75
|
#3 昭和47年12月 1972年12月
|
84
76
|
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
85
81
|
```
|