find timezone based on locale
All checks were successful
Lint and Format Check / lint-and-format (pull_request) Successful in 10s
All checks were successful
Lint and Format Check / lint-and-format (pull_request) Successful in 10s
This commit is contained in:
parent
a08d0c0e9b
commit
f07d4d6756
3 changed files with 27 additions and 0 deletions
22
package-lock.json
generated
22
package-lock.json
generated
|
@ -17,6 +17,7 @@
|
|||
"discord-player": "^6.7.1",
|
||||
"discord.js": "^14.16.2",
|
||||
"mediaplex": "^0.0.9",
|
||||
"moment-timezone": "^0.5.45",
|
||||
"sqlite3": "^5.1.7",
|
||||
"typescript": "^5.6.2",
|
||||
"uuid": "^10.0.0"
|
||||
|
@ -3291,6 +3292,27 @@
|
|||
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.30.1",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
|
||||
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.45",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz",
|
||||
"integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"moment": "^2.29.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"discord-player": "^6.7.1",
|
||||
"discord.js": "^14.16.2",
|
||||
"mediaplex": "^0.0.9",
|
||||
"moment-timezone": "^0.5.45",
|
||||
"sqlite3": "^5.1.7",
|
||||
"typescript": "^5.6.2",
|
||||
"uuid": "^10.0.0"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import moment from "moment-timezone";
|
||||
|
||||
/**
|
||||
* Parsed string adapted with TZ (locales) and format for the specified lang
|
||||
* @param tz Lang
|
||||
|
@ -6,7 +8,9 @@
|
|||
* @returns String
|
||||
*/
|
||||
export const showDate = (tz: string, locale: Map<string, unknown>, date: Date) => {
|
||||
const localeInfo = new Intl.Locale(tz);
|
||||
const formattedDate = new Intl.DateTimeFormat(tz, {
|
||||
timeZone: moment.tz.zonesForCountry(localeInfo.region ?? localeInfo.baseName)[0],
|
||||
dateStyle: "short",
|
||||
timeStyle: "medium",
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue