⬆️ 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:
Tagaishi
2023-09-01 17:15:25 +02:00
committed by GitHub
parent 78627f7b51
commit eb3bbfb025
3 changed files with 1423 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
import { z } from 'zod';
import { find } from 'geo-tz'
const GeoTz = require('browser-geo-tz/dist/geotz.js');
import { createTRPCRouter, publicProcedure } from '../trpc';
@@ -12,6 +12,7 @@ export const timezoneRouter = createTRPCRouter({
})
)
.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;
}),
})