⬆️ geo-tz to browser-geo-tz (#1322)
* ⬆️ geo-tz to tz-lookup * 🐛 Handle multiple timezones return * ⬆️ change tz-lookup to browser-geo-tz
This commit is contained in:
@@ -61,13 +61,13 @@
|
|||||||
"@trpc/server": "^10.29.1",
|
"@trpc/server": "^10.29.1",
|
||||||
"@vitejs/plugin-react": "^4.0.0",
|
"@vitejs/plugin-react": "^4.0.0",
|
||||||
"axios": "^1.0.0",
|
"axios": "^1.0.0",
|
||||||
|
"browser-geo-tz": "^0.0.4",
|
||||||
"consola": "^3.0.0",
|
"consola": "^3.0.0",
|
||||||
"cookies-next": "^2.1.1",
|
"cookies-next": "^2.1.1",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"dockerode": "^3.3.2",
|
"dockerode": "^3.3.2",
|
||||||
"fily-publish-gridstack": "^0.0.13",
|
"fily-publish-gridstack": "^0.0.13",
|
||||||
"framer-motion": "^10.0.0",
|
"framer-motion": "^10.0.0",
|
||||||
"geo-tz": "^7.0.7",
|
|
||||||
"html-entities": "^2.3.3",
|
"html-entities": "^2.3.3",
|
||||||
"i18next": "^22.5.1",
|
"i18next": "^22.5.1",
|
||||||
"immer": "^10.0.2",
|
"immer": "^10.0.2",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { find } from 'geo-tz'
|
const GeoTz = require('browser-geo-tz/dist/geotz.js');
|
||||||
|
|
||||||
import { createTRPCRouter, publicProcedure } from '../trpc';
|
import { createTRPCRouter, publicProcedure } from '../trpc';
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ export const timezoneRouter = createTRPCRouter({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return find(input.latitude,input.longitude)[0];
|
const timezone = GeoTz.find(input.latitude,input.longitude);
|
||||||
|
return Array.isArray(timezone) ? timezone[0] : timezone;
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user