/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { settings } from "."; interface regexes { imperial: { [key: string]: { regex: RegExp, convert: (...groups: string[]) => string; }; }; metric: { [key: string]: { regex: RegExp, convert: (...groups: string[]) => string; }; }; } // TODO: add grams, kilograms, ounces, and pounds const regexes: regexes = { // matches imperial units, converts them to metric imperial: { farenheight: { regex: /(-?\d+(?:\.\d+)?)°?(f)(?!\w)/ig, convert(...groups) { const c = ((parseFloat(groups[1]) - 32) * (5 / 9)).toFixed(2); return `${c}°C`; }, }, // feetMark: { // regex: /(\d+(?:\.\d+))(')(?!(\d+(?:\.\d+)?(''|")|'))/g, // convert(...groups) { // }, // }, // leaving this one in because it is commonly used for something like 5'9'' for a persons height feetInchesMark: { regex: /(\d+)(') ?(\d+(?:\.\d+)?)("|'')?/g, convert(...groups) { let ftin = parseFloat(groups[1]) / 3.281; ftin += parseFloat(groups[3]) / 39.37; return `${ftin.toFixed(2)}m`; }, }, // inchesMark: { // regex: /(?