migrate timezones-list lib to @vvo/tzdb issue #4479 (#4521)

This commit is contained in:
Huzaifa Azim 2024-03-03 14:54:14 +05:00 committed by GitHub
parent 4c683da0dd
commit 8fd713d642
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 15 deletions

13
package-lock.json generated
View File

@ -12,6 +12,7 @@
"@grpc/grpc-js": "~1.7.3", "@grpc/grpc-js": "~1.7.3",
"@louislam/ping": "~0.4.4-mod.1", "@louislam/ping": "~0.4.4-mod.1",
"@louislam/sqlite3": "15.1.6", "@louislam/sqlite3": "15.1.6",
"@vvo/tzdb": "^6.125.0",
"args-parser": "~1.3.0", "args-parser": "~1.3.0",
"axios": "~0.28.0", "axios": "~0.28.0",
"axios-ntlm": "1.3.0", "axios-ntlm": "1.3.0",
@ -124,7 +125,6 @@
"stylelint-config-standard": "~25.0.0", "stylelint-config-standard": "~25.0.0",
"terser": "~5.15.0", "terser": "~5.15.0",
"test": "~3.3.0", "test": "~3.3.0",
"timezones-list": "~3.0.1",
"typescript": "~4.4.4", "typescript": "~4.4.4",
"v-pagination-3": "~0.1.7", "v-pagination-3": "~0.1.7",
"vite": "~5.0.10", "vite": "~5.0.10",
@ -4672,6 +4672,11 @@
"vue": ">=3.2.0" "vue": ">=3.2.0"
} }
}, },
"node_modules/@vvo/tzdb": {
"version": "6.125.0",
"resolved": "https://registry.npmjs.org/@vvo/tzdb/-/tzdb-6.125.0.tgz",
"integrity": "sha512-zxOP62q3CUYIIe6sL/IK6AhmhnPUuHPNx86qZTXuzQHo/QhQRTfXb331poUStTDdZgBoLc6BADUATbGGN/1d4A=="
},
"node_modules/abbrev": { "node_modules/abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -13303,12 +13308,6 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/timezones-list": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/timezones-list/-/timezones-list-3.0.3.tgz",
"integrity": "sha512-C+Vdvvj2c1xB6pu81pOX8geo6mrk/QsudFVlTVQET7QQwu8WAIyhDNeCrK5grU7EMzmbKLWqz7uU6dN8fvQvPQ==",
"dev": true
},
"node_modules/to-fast-properties": { "node_modules/to-fast-properties": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",

View File

@ -77,6 +77,7 @@
"@grpc/grpc-js": "~1.7.3", "@grpc/grpc-js": "~1.7.3",
"@louislam/ping": "~0.4.4-mod.1", "@louislam/ping": "~0.4.4-mod.1",
"@louislam/sqlite3": "15.1.6", "@louislam/sqlite3": "15.1.6",
"@vvo/tzdb": "^6.125.0",
"args-parser": "~1.3.0", "args-parser": "~1.3.0",
"axios": "~0.28.0", "axios": "~0.28.0",
"axios-ntlm": "1.3.0", "axios-ntlm": "1.3.0",
@ -189,7 +190,6 @@
"stylelint-config-standard": "~25.0.0", "stylelint-config-standard": "~25.0.0",
"terser": "~5.15.0", "terser": "~5.15.0",
"test": "~3.3.0", "test": "~3.3.0",
"timezones-list": "~3.0.1",
"typescript": "~4.4.4", "typescript": "~4.4.4",
"v-pagination-3": "~0.1.7", "v-pagination-3": "~0.1.7",
"vite": "~5.0.10", "vite": "~5.0.10",

View File

@ -1,5 +1,5 @@
import dayjs from "dayjs"; import dayjs from "dayjs";
import timezones from "timezones-list"; import { getTimeZones } from "@vvo/tzdb";
import { localeDirection, currentLocale } from "./i18n"; import { localeDirection, currentLocale } from "./i18n";
import { POSITION } from "vue-toastification"; import { POSITION } from "vue-toastification";
@ -29,18 +29,19 @@ function getTimezoneOffset(timeZone) {
*/ */
export function timezoneList() { export function timezoneList() {
let result = []; let result = [];
const timeZones = getTimeZones();
for (let timezone of timezones) { for (let timezone of timeZones) {
try { try {
let display = dayjs().tz(timezone.tzCode).format("Z"); let display = dayjs().tz(timezone.name).format("Z");
result.push({ result.push({
name: `(UTC${display}) ${timezone.tzCode}`, name: `(UTC${display}) ${timezone.name}`,
value: timezone.tzCode, value: timezone.name,
time: getTimezoneOffset(timezone.tzCode), time: getTimezoneOffset(timezone.name),
}); });
} catch (e) { } catch (e) {
// Skipping not supported timezone.tzCode by dayjs // Skipping not supported timezone.name by dayjs
} }
} }