@hypernetlabs/web-ui
Version:
Web ui react components for hypernet protocol
41 lines • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DateUtils = void 0;
class DateUtils {
fromTimestampToUI(dateTimestamp) {
if (dateTimestamp == null)
return "";
const date = new Date(this._getTimestamp(dateTimestamp));
return `${date.getMonth() + 1}/${date.getDate()}/${date.getFullYear()} ${date
.getHours()
.toString()
.padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}`;
}
getCurrentIISODateTime() {
const date = new Date();
return new Date(date.getTime() - date.getTimezoneOffset() * 60000)
.toISOString()
.substring(0, 16);
}
fromDatetimeStringToTimestamp(datetimeString) {
if (datetimeString == null) {
return null;
}
return Date.parse(datetimeString);
}
checkTimestampInRang(timestamp, timestampFrom, timestampTo) {
if (timestampFrom == null || timestampTo == null) {
return true;
}
return (this._getTimestamp(timestamp) >= this._getTimestamp(timestampFrom) &&
this._getTimestamp(timestamp) <= this._getTimestamp(timestampTo));
}
_getTimestamp(timestamp) {
if (`${timestamp}`.length < 11) {
return timestamp * 1000;
}
return timestamp;
}
}
exports.DateUtils = DateUtils;
//# sourceMappingURL=DateUtils.js.map