This commit is contained in:
Dragon Fire
2021-04-24 14:32:50 -04:00
parent 33e9249144
commit d321ecaac3
+11 -6
View File
@@ -13,8 +13,8 @@ module.exports = class TimezoneType extends ArgumentType {
const directZone = moment.tz.zone(value); const directZone = moment.tz.zone(value);
if (directZone) return true; if (directZone) return true;
try { try {
const zipZone = new ZipToTz().full(value); new ZipToTz().full(value);
return zipZone; return true;
} catch { } catch {
const cityZone = cityTimezones.lookupViaCity(value); const cityZone = cityTimezones.lookupViaCity(value);
if (cityZone.length) return true; if (cityZone.length) return true;
@@ -28,10 +28,15 @@ module.exports = class TimezoneType extends ArgumentType {
value = value.replaceAll(' ', '_').toLowerCase(); value = value.replaceAll(' ', '_').toLowerCase();
const directZone = moment.tz.zone(value); const directZone = moment.tz.zone(value);
if (directZone) return directZone.name; if (directZone) return directZone.name;
const cityZone = cityTimezones.lookupViaCity(value); try {
if (cityZone.length) return cityZone[0].timezone; const zipZone = new ZipToTz().full(value);
const provZone = cityTimezones.findFromCityStateProvince(value); return zipZone;
if (provZone.length) return provZone[0].timezone; } catch {
const cityZone = cityTimezones.lookupViaCity(value);
if (cityZone.length) return cityZone[0].timezone;
const provZone = cityTimezones.findFromCityStateProvince(value);
if (provZone.length) return provZone[0].timezone;
}
return null; return null;
} }
}; };