UNPKG

fsw-date-handler

Version:

Biblioteca para tratamento de datas de sistemas Senior G5 em JavaScript.

36 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var date_fns_1 = require("date-fns"); var FSWDateHandler = /** @class */ (function () { function FSWDateHandler() { } // Retorna a data atual em formato de string (G5) FSWDateHandler.prototype.currentDateG5Format = function () { return date_fns_1.format(new Date(), 'dd/MM/yyyy'); }; // Retorna a hora atual em formato de número (G5) FSWDateHandler.prototype.currentHourG5Format = function () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); return (hours * 60) + minutes; }; // Formata uma data JavaScript no formato de string da G5 FSWDateHandler.prototype.jsDateToG5StringFormat = function (jsDate) { return date_fns_1.format(jsDate, 'dd/MM/yyyy'); }; // Formata hora em formato da G5 em string FSWDateHandler.prototype.g5HourToString = function (g5Hour) { var totalHour = g5Hour / 60; var hour = Math.trunc(totalHour).toString().padStart(2, '0'); var minutes = Math.trunc((totalHour - parseInt(hour)) * 60).toString().padStart(2, '0'); return hour + ":" + minutes; }; // Retorna a data nula da G5 (31/12/1900) FSWDateHandler.prototype.nullDateG5Format = function () { return date_fns_1.format(new Date(1900, 11, 31), 'dd/MM/yyyy'); }; return FSWDateHandler; }()); exports.default = FSWDateHandler; //# sourceMappingURL=index.js.map