Comparing version 1.0.22 to 1.0.23
@@ -11,2 +11,3 @@ import { Semaphore } from "./Semaphore"; | ||
export declare const round: (value: number, decimalPlates?: number) => number; | ||
export declare const timeToPercentage: (time: string) => number; | ||
export { Semaphore }; |
@@ -29,7 +29,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Semaphore = exports.round = exports.trunc = exports.delay = exports.replacer = exports.log = exports.getUptimeServer = exports.getPackageJsonData = exports.isEmpty = exports.isNotEmpty = void 0; | ||
exports.Semaphore = exports.timeToPercentage = exports.round = exports.trunc = exports.delay = exports.replacer = exports.log = exports.getUptimeServer = exports.getPackageJsonData = exports.isEmpty = exports.isNotEmpty = void 0; | ||
const fs = __importStar(require("fs")); | ||
const moment_1 = __importDefault(require("moment")); | ||
const Semaphore_1 = require("./Semaphore"); | ||
Object.defineProperty(exports, "Semaphore", { enumerable: true, get: function () { return Semaphore_1.Semaphore; } }); | ||
const fs = __importStar(require("fs")); | ||
const isNotEmpty = (obj) => { | ||
@@ -125,1 +125,16 @@ return !(0, exports.isEmpty)(obj); | ||
exports.round = round; | ||
const timeToPercentage = (time) => { | ||
// Expressão regular para validar o formato HH:mm | ||
const timeFormat = /^([01]\d|2[0-3]):([0-5]\d)$/; | ||
// Verifica se o formato está correto | ||
if (!timeFormat.test(time)) { | ||
throw new Error("Invalid time format, expected HH:mm"); | ||
} | ||
const [hours, minutes] = time.split(":").map(Number); | ||
if (isNaN(hours) || isNaN(minutes)) { | ||
throw new Error("Invalid time format"); | ||
} | ||
// Convert hours and minutes to the percentage equivalent | ||
return hours + (minutes / 60); | ||
}; | ||
exports.timeToPercentage = timeToPercentage; |
{ | ||
"name": "c2-util", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "Biblioteca de funções utilitárias", | ||
@@ -5,0 +5,0 @@ "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-util.git", |
8263
201