UNPKG

ifc-expressions

Version:

Parsing and evaluation of IFC expressions

59 lines (58 loc) 1.85 kB
import { Decimal } from "decimal.js"; import { Type } from "../type/Types.js"; import { isNullish } from "../IfcExpression.js"; import { DateFormatException } from "../error/value/DateFormatException.js"; import { IfcDateTimeValue } from "./IfcDateTimeValue.js"; export class IfcTimeStampValue { constructor(value) { if (typeof value === "string") { this.timeStamp = new Decimal(value); } else if (typeof value === "number") { this.timeStamp = new Decimal(value); } else { if (value.isInteger()) { this.timeStamp = value; } else { throw new DateFormatException("Not a valid IfcTimeStamp: " + value.toString()); } } if (isNullish(this.timeStamp) || this.timeStamp.isNaN() || !this.timeStamp.isFinite()) { throw new DateFormatException("Not a valid IfcTimeStamp: " + value); } } static of(value) { return new IfcTimeStampValue(value); } getValue() { return this; } getType() { return Type.IFC_TIME_STAMP; } static isIfcTimeStampValueType(arg) { return (arg instanceof IfcTimeStampValue || (!isNullish(arg.timeStamp) && arg.timeStamp instanceof Decimal)); } equals(other) { return (IfcTimeStampValue.isIfcTimeStampValueType(other) && this.timeStamp.eq(other.timeStamp)); } toString() { return this.timeStamp.toString(); } compareTo(other) { return this.timeStamp.comparedTo(other.timeStamp); } getTimeStampSeconds() { return this.timeStamp; } toIfcDateTimeValue() { return IfcDateTimeValue.ofTimeStampSeconds(this.timeStamp); } } //# sourceMappingURL=IfcTimeStampValue.js.map