【JavaScript JSX ES 6】アラビア数字日付と時間は中国語で大文字に変換されます.
4864 ワード
const numberToCN = [' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
' ',' ',' '];// ,
export function DateAndTimeTrans(datetime){
//2015-07-18 08:30
let result = "";
result += numberToCN[datetime[0]];
result += numberToCN[datetime[1]];
result += numberToCN[datetime[2]];
result += numberToCN[datetime[3]];
result += " ";
result += numberToCN[new Number(datetime.substr(5,2))];
result += " "
result += numberToCN[new Number(datetime.substr(8,2))];
result += " "
result += numberToCN[new Number(datetime.substr(11,2))];
result += " ";
let tmp = numberToCN[new Number(datetime.substr(14,2))];
result += tmp == " " ? " " : tmp + " ";
return result;
}
正規表現の書き方があるはずです.後で書きます.