Skip to content

Commit 06c2686

Browse files
fix(core): use [zh-CN](https://www.techonthenet.com/js/language_tags.php) language tags option in timeTransformer function
1 parent ab96e75 commit 06c2686

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1+
const options: Intl.DateTimeFormatOptions = {
2+
year: "numeric",
3+
month: "2-digit",
4+
day: "2-digit",
5+
hour: "2-digit",
6+
minute: "2-digit",
7+
second: "2-digit",
8+
hour12: false,
9+
};
10+
111
/**
212
* get current time in format: YYYY-MM-DD-HH-mm-ss
313
* @param timestamp - Timestamp
414
* @param lang - Language
515
* @param dateOptions - Date options
616
* @returns - Date string
717
*/
8-
export function timeTransformer(timestamp = new Date(), lang = "cn", dateOptions = {}) {
18+
export function timeTransformer(timestamp = new Date(), lang = "zh-CN", dateOptions = options) {
919
return new Date(timestamp).toLocaleString(lang, dateOptions).replaceAll(/(\/|\:|)/g, "").replace(/\s/, "-");
1020
}

0 commit comments

Comments
 (0)