fix number calling
This commit is contained in:
parent
ae3339e49f
commit
92f9794beb
2 changed files with 7 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ export default class CallingNumberKorean {
|
||||||
"여섯", "일곱", "여덟", "아홉", "열",
|
"여섯", "일곱", "여덟", "아홉", "열",
|
||||||
]
|
]
|
||||||
static canConvert(num: number): boolean {
|
static canConvert(num: number): boolean {
|
||||||
return num < 100 && num >= 0 && !Number.isInteger(num)
|
return num < 100 && num >= 0 && Number.isInteger(num)
|
||||||
}
|
}
|
||||||
static convert(num: number): string {
|
static convert(num: number): string {
|
||||||
const firstDigit = num % 10;
|
const firstDigit = num % 10;
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,10 @@ export function saferKorean(input: string): string {
|
||||||
const hasNoSuffix = suffix == "";
|
const hasNoSuffix = suffix == "";
|
||||||
|
|
||||||
if (hasNoSuffix && dotCount == 0) {
|
if (hasNoSuffix && dotCount == 0) {
|
||||||
|
// 일반 숫자는 인트로 읽음
|
||||||
return IntegerKorean.convertFromString(num) + postfix;
|
return IntegerKorean.convertFromString(num) + postfix;
|
||||||
} else if (hasNoSuffix && dotCount == 1) {
|
} else if (hasNoSuffix && dotCount == 1) {
|
||||||
|
// 소수는 . 앞은 인트로, 뒤는 플로트로 읽음
|
||||||
const [intPart, floatPart] = num.split(/\./);
|
const [intPart, floatPart] = num.split(/\./);
|
||||||
return (
|
return (
|
||||||
IntegerKorean.convertFromString(intPart)
|
IntegerKorean.convertFromString(intPart)
|
||||||
|
|
@ -184,7 +186,8 @@ export function saferKorean(input: string): string {
|
||||||
+ FloatKorean.convert(floatPart)
|
+ FloatKorean.convert(floatPart)
|
||||||
+ postfix
|
+ postfix
|
||||||
)
|
)
|
||||||
} else if (suffix == "v") {
|
} else if ((suffix == "v" || postfix.length) && dotCount > 1) {
|
||||||
|
// 버전표기는 버전을 붙여서
|
||||||
return (
|
return (
|
||||||
"버전"
|
"버전"
|
||||||
+ FloatKorean.convert(num)
|
+ FloatKorean.convert(num)
|
||||||
|
|
@ -193,6 +196,8 @@ export function saferKorean(input: string): string {
|
||||||
] ?? "")
|
] ?? "")
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// 모든 경우에 속하지 않으면 영일이삼사 형태로 읽음
|
||||||
|
// (예: 111.111.111.111 ip address)
|
||||||
return FloatKorean.convert(num) + postfix;
|
return FloatKorean.convert(num) + postfix;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue