ifc-expressions 2.2.0-beta.0 → 2.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/IfcExpression.d.ts +6 -1
  2. package/dist/cjs/IfcExpression.js +11 -1
  3. package/dist/cjs/IfcExpression.js.map +1 -1
  4. package/dist/cjs/value/IfcDateTimeValue.js +34 -21
  5. package/dist/cjs/value/IfcDateTimeValue.js.map +1 -1
  6. package/dist/cjs/value/IfcDateValue.js +13 -6
  7. package/dist/cjs/value/IfcDateValue.js.map +1 -1
  8. package/dist/cjs/value/IfcDurationValue.js +1 -1
  9. package/dist/cjs/value/IfcDurationValue.js.map +1 -1
  10. package/dist/cjs/value/IfcTimeValue.js +9 -6
  11. package/dist/cjs/value/IfcTimeValue.js.map +1 -1
  12. package/dist/cjs/value/Value.js.map +1 -1
  13. package/dist/cjs/value/{NonBoxedValueTypes.js → ValueType.js} +1 -1
  14. package/dist/cjs/value/ValueType.js.map +1 -0
  15. package/dist/mjs/IfcExpression.js +6 -1
  16. package/dist/mjs/IfcExpression.js.map +1 -1
  17. package/dist/mjs/value/IfcDateTimeValue.js +34 -21
  18. package/dist/mjs/value/IfcDateTimeValue.js.map +1 -1
  19. package/dist/mjs/value/IfcDateValue.js +13 -6
  20. package/dist/mjs/value/IfcDateValue.js.map +1 -1
  21. package/dist/mjs/value/IfcDurationValue.js +1 -1
  22. package/dist/mjs/value/IfcDurationValue.js.map +1 -1
  23. package/dist/mjs/value/IfcTimeValue.js +9 -6
  24. package/dist/mjs/value/IfcTimeValue.js.map +1 -1
  25. package/dist/mjs/value/Value.js.map +1 -1
  26. package/dist/mjs/value/ValueType.js +2 -0
  27. package/dist/mjs/value/ValueType.js.map +1 -0
  28. package/dist/value/IfcDateTimeValue.d.ts +4 -1
  29. package/dist/value/IfcDateValue.d.ts +2 -0
  30. package/dist/value/IfcTimeValue.d.ts +2 -0
  31. package/dist/value/Value.d.ts +2 -2
  32. package/dist/value/{NonBoxedValueTypes.d.ts → ValueType.d.ts} +1 -1
  33. package/package.json +1 -1
  34. package/dist/cjs/value/NonBoxedValueTypes.js.map +0 -1
  35. package/dist/mjs/value/NonBoxedValueTypes.js +0 -2
  36. package/dist/mjs/value/NonBoxedValueTypes.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { NonBoxedValueTypes } from \"./NonBoxedValueTypes.js\";\n\nexport interface Value<\n T extends\n | NonBoxedValueTypes\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n getType(): ExprType;\n}\n"]}
1
+ {"version":3,"sources":["../../src/value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { ValueType } from \"./ValueType\";\n\nexport interface Value<\n T extends\n | ValueType\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n getType(): ExprType;\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=NonBoxedValueTypes.js.map
3
+ //# sourceMappingURL=ValueType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/value/ValueType.ts"],"names":[],"mappings":"","file":"value/ValueType.js","sourcesContent":["import { IfcDateTimeValue } from \"./IfcDateTimeValue.js\";\nimport { IfcDateValue } from \"./IfcDateValue.js\";\nimport { IfcTimeValue } from \"./IfcTimeValue.js\";\nimport { IfcDurationValue } from \"./IfcDurationValue.js\";\nimport { IfcTimeStampValue } from \"./IfcTimeStampValue.js\";\n\nexport type ValueType =\n | IfcDateValue\n | IfcDateTimeValue\n | IfcTimeValue\n | IfcDurationValue\n | IfcTimeStampValue;\n"]}
@@ -25,7 +25,12 @@ import { mapException } from "./error/ExceptionToExprEvalErrorMapper.js";
25
25
  import { NopContext } from "./context/NopContext.js";
26
26
  import { ExprToTextInputLinker } from "./compiler/ExprToTextInputLinker.js";
27
27
  import { ExprFacade } from "./expression/ExprFacade.js";
28
- export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, };
28
+ import { IfcDurationValue } from "./value/IfcDurationValue.js";
29
+ import { IfcDateValue } from "./value/IfcDateValue.js";
30
+ import { IfcDateTimeValue } from "./value/IfcDateTimeValue.js";
31
+ import { IfcTimeValue } from "./value/IfcTimeValue.js";
32
+ import { IfcTimeStampValue } from "./value/IfcTimeStampValue.js";
33
+ export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcDateValue, IfcDateTimeValue, IfcTimeValue, IfcDurationValue, IfcTimeStampValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, };
29
34
  export class IfcExpressionParseResult {
30
35
  constructor(input, typeManager, exprContext) {
31
36
  this._typeManager = typeManager;
@@ -1 +1 @@
1
- {"version":3,"sources":["IfcExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,U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I,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1D;QACD,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,EAAU;QACzC,OAAO,CAAC;aACL,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aACpC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,IAAiC,EACjC,UAAgC,IAAI,UAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
1
+ {"version":3,"sources":["IfcExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EAGjB,eAAe,GAEhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,SAAS,EA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AC;YACnE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1D;QACD,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,EAAU;QACzC,OAAO,CAAC;aACL,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aACpC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,IAAiC,EACjC,UAAgC,IAAI,UAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
@@ -9,32 +9,36 @@ export class IfcDateTimeValue {
9
9
  constructor(value) {
10
10
  if (typeof value === "string") {
11
11
  var parsed = IfcDateTimeValue.parseIfcDate(value);
12
- this.utcDateValue = parsed.utcDate;
12
+ this.utcDate = parsed.utcDate;
13
13
  this.originalTimeZoneHours = parsed.originalTimeZoneHours;
14
14
  this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;
15
15
  this.secondFraction = parsed.secondFraction;
16
+ this.isLocal = parsed.isLocal;
16
17
  }
17
18
  else if (typeof value === "number" || value instanceof Decimal) {
18
19
  let timeStampSeconds = value;
19
20
  if (value instanceof Decimal) {
20
21
  timeStampSeconds = value.round().toNumber();
21
22
  }
22
- this.utcDateValue = new Date(timeStampSeconds);
23
+ this.utcDate = new Date(timeStampSeconds);
23
24
  this.originalTimeZoneHours = 0;
24
25
  this.originalTimeZoneMinutes = 0;
25
26
  this.secondFraction = new Decimal(0);
27
+ this.isLocal = false;
26
28
  }
27
29
  else if (value instanceof IfcDateTimeValue) {
28
- this.utcDateValue = value.utcDateValue;
30
+ this.utcDate = value.utcDate;
29
31
  this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;
30
32
  this.originalTimeZoneHours = value.originalTimeZoneHours;
31
33
  this.secondFraction = value.secondFraction;
34
+ this.isLocal = value.isLocal;
32
35
  }
33
36
  else if (isParsedIfcDateTimeValue(value)) {
34
- this.utcDateValue = value.utcDate;
37
+ this.utcDate = value.utcDate;
35
38
  this.secondFraction = value.secondFraction;
36
39
  this.originalTimeZoneHours = value.originalTimeZoneHours;
37
40
  this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;
41
+ this.isLocal = value.isLocal;
38
42
  }
39
43
  this.stringRepresentation = this.toCanonicalString();
40
44
  }
@@ -52,18 +56,19 @@ export class IfcDateTimeValue {
52
56
  utcDate.setUTCHours(Number.parseInt(hours));
53
57
  utcDate.setUTCMinutes(Number.parseInt(minutes));
54
58
  utcDate.setUTCSeconds(Number.parseInt(seconds));
55
- var secondFraction = isNullish(fractionSeconds)
59
+ const secondFraction = isNullish(fractionSeconds)
56
60
  ? new Decimal("0")
57
61
  : new Decimal("0" + fractionSeconds); //arbitrary precision fractions (to the precision of Decimal.precision)
58
- var originalZoneSign = isNullish(timeZoneSign)
62
+ const originalZoneSign = isNullish(timeZoneSign)
59
63
  ? 0
60
64
  : timeZoneSign === "+"
61
65
  ? 1
62
66
  : -1;
63
- var originalTimeZoneHours = originalZoneSign *
67
+ const originalTimeZoneHours = originalZoneSign *
64
68
  (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));
65
- var originalTimeZoneMinutes = originalZoneSign *
69
+ const originalTimeZoneMinutes = originalZoneSign *
66
70
  (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));
71
+ const isLocal = isNullish(timeZoneWhole);
67
72
  utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);
68
73
  utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);
69
74
  return {
@@ -71,6 +76,7 @@ export class IfcDateTimeValue {
71
76
  secondFraction,
72
77
  originalTimeZoneHours,
73
78
  originalTimeZoneMinutes,
79
+ isLocal,
74
80
  };
75
81
  }
76
82
  static of(value) {
@@ -82,15 +88,18 @@ export class IfcDateTimeValue {
82
88
  : this.secondFraction.isZero()
83
89
  ? ""
84
90
  : this.secondFraction.toString().substring(1);
85
- return `${this.pad00(this.utcDateValue.getUTCHours() + this.originalTimeZoneHours)}:${this.pad00(this.utcDateValue.getUTCMinutes() + this.originalTimeZoneMinutes)}:${this.pad00(this.utcDateValue.getUTCSeconds())}${fraction}`;
91
+ return `${this.pad00(this.utcDate.getUTCHours() + this.originalTimeZoneHours)}:${this.pad00(this.utcDate.getUTCMinutes() + this.originalTimeZoneMinutes)}:${this.pad00(this.utcDate.getUTCSeconds())}${fraction}`;
86
92
  }
87
93
  pad00(num) {
88
94
  return ("" + num).padStart(2, "0");
89
95
  }
90
96
  getDateAsString() {
91
- return `${this.utcDateValue.getUTCFullYear()}-${this.pad00(this.utcDateValue.getUTCMonth() + 1)}-${this.pad00(this.utcDateValue.getUTCDate())}`;
97
+ return `${this.utcDate.getUTCFullYear()}-${this.pad00(this.utcDate.getUTCMonth() + 1)}-${this.pad00(this.utcDate.getUTCDate())}`;
92
98
  }
93
99
  getTimeZoneAsString() {
100
+ if (this.isLocal) {
101
+ return "";
102
+ }
94
103
  if (this.originalTimeZoneMinutes === 0 &&
95
104
  this.originalTimeZoneHours === 0) {
96
105
  return "Z";
@@ -101,7 +110,14 @@ export class IfcDateTimeValue {
101
110
  return `${sign}${this.pad00(Math.abs(this.originalTimeZoneHours))}:${this.pad00(Math.abs(this.originalTimeZoneMinutes))}`;
102
111
  }
103
112
  getTimeStampSeconds() {
104
- return new Decimal(this.utcDateValue.getTime()).divToInt(1000);
113
+ const offset = this.isLocal ? new Date().getTimezoneOffset() * 60 : 0;
114
+ return new Decimal(this.utcDate.getTime()).divToInt(1000).minus(offset);
115
+ }
116
+ getTime() {
117
+ const offset = this.isLocal ? new Date().getTimezoneOffset() * 60 : 0;
118
+ return new Decimal(this.utcDate.getTime())
119
+ .minus(offset)
120
+ .plus(this.secondFraction);
105
121
  }
106
122
  getValue() {
107
123
  return this;
@@ -115,12 +131,11 @@ export class IfcDateTimeValue {
115
131
  !isNullish(arg.stringRepresentation.match(IfcDateTimeValue.regex))));
116
132
  }
117
133
  static isValidStringRepresentation(str) {
118
- return !isNullish(str.match(this.regex));
134
+ return this.regex.test(str);
119
135
  }
120
136
  equals(other) {
121
137
  return (IfcDateTimeValue.isIfcDateTimeValueType(other) &&
122
- this.utcDateValue.getTime() === other.utcDateValue.getTime() &&
123
- this.secondFraction.eq(other.secondFraction));
138
+ this.getTime().eq(other.getTime()));
124
139
  }
125
140
  toCanonicalString() {
126
141
  return (this.getDateAsString() +
@@ -132,11 +147,7 @@ export class IfcDateTimeValue {
132
147
  return this.stringRepresentation;
133
148
  }
134
149
  compareTo(other) {
135
- var diff = this.utcDateValue.getTime() - other.utcDateValue.getTime();
136
- if (diff != 0) {
137
- return diff;
138
- }
139
- return Decimal.sign(this.secondFraction.minus(other.secondFraction));
150
+ return Decimal.sign(this.getTime().minus(other.getTime()));
140
151
  }
141
152
  static ofTimeStampSeconds(timeStampSeconds) {
142
153
  var timeStampMillis = timeStampSeconds;
@@ -156,7 +167,7 @@ export class IfcDateTimeValue {
156
167
  return IfcTimeStampValue.of(this.getTimeStampSeconds());
157
168
  }
158
169
  addDuration(duration) {
159
- const resultDate = new Date(this.utcDateValue.getTime());
170
+ const resultDate = new Date(this.utcDate.getTime());
160
171
  const accumulatedFractions = this.secondFraction.add(duration.getFractionAsSeconds());
161
172
  const newSecondFraction = accumulatedFractions.minus(accumulatedFractions.divToInt(1));
162
173
  resultDate.setUTCSeconds(resultDate.getUTCSeconds() + accumulatedFractions.divToInt(1).toNumber());
@@ -173,6 +184,7 @@ export class IfcDateTimeValue {
173
184
  secondFraction: newSecondFraction,
174
185
  originalTimeZoneHours: this.originalTimeZoneHours,
175
186
  originalTimeZoneMinutes: this.originalTimeZoneMinutes,
187
+ isLocal: this.isLocal,
176
188
  });
177
189
  }
178
190
  }
@@ -181,6 +193,7 @@ export function isParsedIfcDateTimeValue(arg) {
181
193
  return (!isNullish(arg.utcDate) &&
182
194
  !isNullish(arg.secondFraction) &&
183
195
  !isNullish(arg.originalTimeZoneHours) &&
184
- !isNullish(arg.originalTimeZoneMinutes));
196
+ !isNullish(arg.originalTimeZoneMinutes) &&
197
+ !isNullish(arg.isLocal));
185
198
  }
186
199
  //# sourceMappingURL=IfcDateTimeValue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["value/IfcDateTimeValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,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EAAE,CACvE,CAAC;QACF,UAAU,CAAC,cAAc,CACvB,UAAU,CAAC,cAAc,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACzE,CAAC;QACF,OAAO,IAAI,gBAAgB,CAAC;YAC1B,OAAO,EAAE,UAAU;YACnB,cAAc,EAAE,iBAAiB;YACjC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;YACjD,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAC,CAAC;IACL,CAAC;;AAlPuB,sBAAK,GAC3B,iMAAiM,CAAC;AA2PtM,MAAM,UAAU,wBAAwB,CACtC,GAAQ;IAER,OAAO,CACL,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC;QACvB,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;QAC9B,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC;QACrC,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CACxC,CAAC;AACJ,CAAC","file":"value/IfcDateTimeValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\nimport { IfcDateValue } from \"./IfcDateValue.js\";\nimport { IfcTimeValue } from \"./IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./IfcTimeStampValue.js\";\nimport { IfcDurationValue } from \"./IfcDurationValue.js\";\n\nexport class IfcDateTimeValue\n implements Value<IfcDateTimeValue>, Comparable<IfcDateTimeValue>\n{\n private readonly utcDateValue: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private readonly secondFraction: Decimal;\n private static readonly regex =\n /^([+\\-]?(?:[1-9]\\d*)?\\d{4}(?<!0000))-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|(?<=23:59:)60)(\\.\\d+)?(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(\n value: string | number | Decimal | IfcDateTimeValue | ParsedIfcDateTimeValue\n ) {\n if (typeof value === \"string\") {\n var parsed = IfcDateTimeValue.parseIfcDate(value);\n this.utcDateValue = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.secondFraction = parsed.secondFraction;\n } else if (typeof value === \"number\" || value instanceof Decimal) {\n let timeStampSeconds = value;\n if (value instanceof Decimal) {\n timeStampSeconds = (value as Decimal).round().toNumber();\n }\n this.utcDateValue = new Date(timeStampSeconds as number);\n this.originalTimeZoneHours = 0;\n this.originalTimeZoneMinutes = 0;\n this.secondFraction = new Decimal(0);\n } else if (value instanceof IfcDateTimeValue) {\n this.utcDateValue = value.utcDateValue;\n this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;\n this.originalTimeZoneHours = value.originalTimeZoneHours;\n this.secondFraction = value.secondFraction;\n } else if (isParsedIfcDateTimeValue(value)) {\n this.utcDateValue = value.utcDate;\n this.secondFraction = value.secondFraction;\n this.originalTimeZoneHours = value.originalTimeZoneHours;\n this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;\n }\n this.stringRepresentation = this.toCanonicalString();\n }\n\n public static parseIfcDate(value: string): ParsedIfcDateTimeValue {\n Decimal.set({ defaults: true });\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDateTime: \" + value);\n }\n let [\n wholeString,\n year,\n month,\n day,\n hours,\n minutes,\n seconds,\n fractionSeconds,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n var utcDate = new Date(0);\n utcDate.setUTCFullYear(Number.parseInt(year));\n utcDate.setUTCMonth(Number.parseInt(month) - 1);\n utcDate.setUTCDate(Number.parseInt(day));\n utcDate.setUTCHours(Number.parseInt(hours));\n utcDate.setUTCMinutes(Number.parseInt(minutes));\n utcDate.setUTCSeconds(Number.parseInt(seconds));\n var secondFraction = isNullish(fractionSeconds)\n ? new Decimal(\"0\")\n : new Decimal(\"0\" + fractionSeconds); //arbitrary precision fractions (to the precision of Decimal.precision)\n var originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? 1\n : -1;\n var originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n var originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);\n return {\n utcDate,\n secondFraction,\n originalTimeZoneHours,\n originalTimeZoneMinutes,\n };\n }\n\n public static of(value: string): IfcDateTimeValue {\n return new IfcDateTimeValue(value);\n }\n\n private getTimeAsString() {\n const fraction = isNullish(this.secondFraction)\n ? \"\"\n : this.secondFraction.isZero()\n ? \"\"\n : this.secondFraction.toString().substring(1);\n return `${this.pad00(\n this.utcDateValue.getUTCHours() + this.originalTimeZoneHours\n )}:${this.pad00(\n this.utcDateValue.getUTCMinutes() + this.originalTimeZoneMinutes\n )}:${this.pad00(this.utcDateValue.getUTCSeconds())}${fraction}`;\n }\n\n private pad00(num: number): string {\n return (\"\" + num).padStart(2, \"0\");\n }\n\n private getDateAsString() {\n return `${this.utcDateValue.getUTCFullYear()}-${this.pad00(\n this.utcDateValue.getUTCMonth() + 1\n )}-${this.pad00(this.utcDateValue.getUTCDate())}`;\n }\n\n getTimeZoneAsString(): String {\n if (\n this.originalTimeZoneMinutes === 0 &&\n this.originalTimeZoneHours === 0\n ) {\n return \"Z\";\n }\n const sign =\n this.originalTimeZoneHours >= 0 && this.originalTimeZoneMinutes >= 0\n ? \"+\"\n : \"-\";\n return `${sign}${this.pad00(\n Math.abs(this.originalTimeZoneHours)\n )}:${this.pad00(Math.abs(this.originalTimeZoneMinutes))}`;\n }\n\n private getTimeStampSeconds(): Decimal {\n return new Decimal(this.utcDateValue.getTime()).divToInt(1000);\n }\n\n getValue(): IfcDateTimeValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DATE_TIME;\n }\n\n static isIfcDateTimeValueType(arg: any): arg is IfcDateTimeValue {\n return (\n arg instanceof IfcDateTimeValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDateTimeValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return !isNullish(str.match(this.regex));\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDateTimeValue.isIfcDateTimeValueType(other) &&\n this.utcDateValue.getTime() === other.utcDateValue.getTime() &&\n this.secondFraction.eq(other.secondFraction)\n );\n }\n\n private toCanonicalString(): string {\n return (\n this.getDateAsString() +\n \"T\" +\n this.getTimeAsString() +\n this.getTimeZoneAsString()\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDateTimeValue): number {\n var diff = this.utcDateValue.getTime() - other.utcDateValue.getTime();\n if (diff != 0) {\n return diff;\n }\n return Decimal.sign(this.secondFraction.minus(other.secondFraction));\n }\n\n static ofTimeStampSeconds(timeStampSeconds: Decimal | number) {\n var timeStampMillis = timeStampSeconds;\n if (timeStampSeconds instanceof Decimal) {\n timeStampMillis = timeStampSeconds.round().toNumber();\n }\n timeStampMillis = (timeStampMillis as number) * 1000;\n return new IfcDateTimeValue(timeStampMillis);\n }\n\n toIfcDateValue(): IfcDateValue {\n return IfcDateValue.of(this.getDateAsString() + this.getTimeZoneAsString());\n }\n\n toIfcTimeValue(): IfcTimeValue {\n return IfcTimeValue.of(this.getTimeAsString() + this.getTimeZoneAsString());\n }\n\n toIfcTimeStampValue(): IfcTimeStampValue {\n return IfcTimeStampValue.of(this.getTimeStampSeconds());\n }\n\n addDuration(duration: IfcDurationValue): IfcDateTimeValue {\n const resultDate = new Date(this.utcDateValue.getTime());\n const accumulatedFractions = this.secondFraction.add(\n duration.getFractionAsSeconds()\n );\n const newSecondFraction = accumulatedFractions.minus(\n accumulatedFractions.divToInt(1)\n );\n resultDate.setUTCSeconds(\n resultDate.getUTCSeconds() + accumulatedFractions.divToInt(1).toNumber()\n );\n resultDate.setUTCSeconds(\n resultDate.getUTCSeconds() + duration.getSeconds().divToInt(1).toNumber()\n );\n resultDate.setUTCMinutes(\n resultDate.getUTCMinutes() + duration.getMinutes().divToInt(1).toNumber()\n );\n resultDate.setUTCHours(\n resultDate.getUTCHours() + duration.getHours().divToInt(1).toNumber()\n );\n resultDate.setUTCDate(\n resultDate.getUTCDate() + duration.getDays().divToInt(1).toNumber()\n );\n resultDate.setUTCDate(\n resultDate.getUTCDate() +\n duration.getWeeks().divToInt(1).times(7).toNumber()\n );\n resultDate.setUTCMonth(\n resultDate.getUTCMonth() + duration.getMonths().divToInt(1).toNumber()\n );\n resultDate.setUTCFullYear(\n resultDate.getUTCFullYear() + duration.getYears().divToInt(1).toNumber()\n );\n return new IfcDateTimeValue({\n utcDate: resultDate,\n secondFraction: newSecondFraction,\n originalTimeZoneHours: this.originalTimeZoneHours,\n originalTimeZoneMinutes: this.originalTimeZoneMinutes,\n });\n }\n}\n\nexport type ParsedIfcDateTimeValue = {\n utcDate: Date;\n secondFraction: Decimal;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n};\n\nexport function isParsedIfcDateTimeValue(\n arg: any\n): arg is ParsedIfcDateTimeValue {\n return (\n !isNullish(arg.utcDate) &&\n !isNullish(arg.secondFraction) &&\n !isNullish(arg.originalTimeZoneHours) &&\n !isNullish(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AAiM,CAAC;AAyQtM,MAAM,UAAU,wBAAwB,CACtC,GAAQ;IAER,OAAO,CACL,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC;QACvB,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;QAC9B,CAAC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC;QACrC,CAAC,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC;QACvC,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CACxB,CAAC;AACJ,CAAC","file":"value/IfcDateTimeValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\nimport { IfcDateValue } from \"./IfcDateValue.js\";\nimport { IfcTimeValue } from \"./IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./IfcTimeStampValue.js\";\nimport { IfcDurationValue } from \"./IfcDurationValue.js\";\n\nexport class IfcDateTimeValue\n implements Value<IfcDateTimeValue>, Comparable<IfcDateTimeValue>\n{\n private readonly utcDate: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private readonly isLocal: boolean;\n private readonly secondFraction: Decimal;\n private static readonly regex =\n /^([+\\-]?(?:[1-9]\\d*)?\\d{4}(?<!0000))-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|(?<=23:59:)60)(\\.\\d+)?(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(\n value: string | number | Decimal | IfcDateTimeValue | ParsedIfcDateTimeValue\n ) {\n if (typeof value === \"string\") {\n var parsed = IfcDateTimeValue.parseIfcDate(value);\n this.utcDate = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.secondFraction = parsed.secondFraction;\n this.isLocal = parsed.isLocal;\n } else if (typeof value === \"number\" || value instanceof Decimal) {\n let timeStampSeconds = value;\n if (value instanceof Decimal) {\n timeStampSeconds = (value as Decimal).round().toNumber();\n }\n this.utcDate = new Date(timeStampSeconds as number);\n this.originalTimeZoneHours = 0;\n this.originalTimeZoneMinutes = 0;\n this.secondFraction = new Decimal(0);\n this.isLocal = false;\n } else if (value instanceof IfcDateTimeValue) {\n this.utcDate = value.utcDate;\n this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;\n this.originalTimeZoneHours = value.originalTimeZoneHours;\n this.secondFraction = value.secondFraction;\n this.isLocal = value.isLocal;\n } else if (isParsedIfcDateTimeValue(value)) {\n this.utcDate = value.utcDate;\n this.secondFraction = value.secondFraction;\n this.originalTimeZoneHours = value.originalTimeZoneHours;\n this.originalTimeZoneMinutes = value.originalTimeZoneMinutes;\n this.isLocal = value.isLocal;\n }\n this.stringRepresentation = this.toCanonicalString();\n }\n\n public static parseIfcDate(value: string): ParsedIfcDateTimeValue {\n Decimal.set({ defaults: true });\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDateTime: \" + value);\n }\n let [\n wholeString,\n year,\n month,\n day,\n hours,\n minutes,\n seconds,\n fractionSeconds,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n var utcDate = new Date(0);\n utcDate.setUTCFullYear(Number.parseInt(year));\n utcDate.setUTCMonth(Number.parseInt(month) - 1);\n utcDate.setUTCDate(Number.parseInt(day));\n utcDate.setUTCHours(Number.parseInt(hours));\n utcDate.setUTCMinutes(Number.parseInt(minutes));\n utcDate.setUTCSeconds(Number.parseInt(seconds));\n const secondFraction = isNullish(fractionSeconds)\n ? new Decimal(\"0\")\n : new Decimal(\"0\" + fractionSeconds); //arbitrary precision fractions (to the precision of Decimal.precision)\n const originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? 1\n : -1;\n const originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n const originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n const isLocal = isNullish(timeZoneWhole);\n utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);\n return {\n utcDate,\n secondFraction,\n originalTimeZoneHours,\n originalTimeZoneMinutes,\n isLocal,\n };\n }\n\n public static of(value: string): IfcDateTimeValue {\n return new IfcDateTimeValue(value);\n }\n\n private getTimeAsString() {\n const fraction = isNullish(this.secondFraction)\n ? \"\"\n : this.secondFraction.isZero()\n ? \"\"\n : this.secondFraction.toString().substring(1);\n return `${this.pad00(\n this.utcDate.getUTCHours() + this.originalTimeZoneHours\n )}:${this.pad00(\n this.utcDate.getUTCMinutes() + this.originalTimeZoneMinutes\n )}:${this.pad00(this.utcDate.getUTCSeconds())}${fraction}`;\n }\n\n private pad00(num: number): string {\n return (\"\" + num).padStart(2, \"0\");\n }\n\n private getDateAsString() {\n return `${this.utcDate.getUTCFullYear()}-${this.pad00(\n this.utcDate.getUTCMonth() + 1\n )}-${this.pad00(this.utcDate.getUTCDate())}`;\n }\n\n getTimeZoneAsString(): String {\n if (this.isLocal) {\n return \"\";\n }\n if (\n this.originalTimeZoneMinutes === 0 &&\n this.originalTimeZoneHours === 0\n ) {\n return \"Z\";\n }\n const sign =\n this.originalTimeZoneHours >= 0 && this.originalTimeZoneMinutes >= 0\n ? \"+\"\n : \"-\";\n return `${sign}${this.pad00(\n Math.abs(this.originalTimeZoneHours)\n )}:${this.pad00(Math.abs(this.originalTimeZoneMinutes))}`;\n }\n\n private getTimeStampSeconds(): Decimal {\n const offset = this.isLocal ? new Date().getTimezoneOffset() * 60 : 0;\n return new Decimal(this.utcDate.getTime()).divToInt(1000).minus(offset);\n }\n\n private getTime(): Decimal {\n const offset = this.isLocal ? new Date().getTimezoneOffset() * 60 : 0;\n return new Decimal(this.utcDate.getTime())\n .minus(offset)\n .plus(this.secondFraction);\n }\n\n getValue(): IfcDateTimeValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DATE_TIME;\n }\n\n static isIfcDateTimeValueType(arg: any): arg is IfcDateTimeValue {\n return (\n arg instanceof IfcDateTimeValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDateTimeValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return this.regex.test(str);\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDateTimeValue.isIfcDateTimeValueType(other) &&\n this.getTime().eq(other.getTime())\n );\n }\n\n private toCanonicalString(): string {\n return (\n this.getDateAsString() +\n \"T\" +\n this.getTimeAsString() +\n this.getTimeZoneAsString()\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDateTimeValue): number {\n return Decimal.sign(this.getTime().minus(other.getTime()));\n }\n\n static ofTimeStampSeconds(timeStampSeconds: Decimal | number) {\n var timeStampMillis = timeStampSeconds;\n if (timeStampSeconds instanceof Decimal) {\n timeStampMillis = timeStampSeconds.round().toNumber();\n }\n timeStampMillis = (timeStampMillis as number) * 1000;\n return new IfcDateTimeValue(timeStampMillis);\n }\n\n toIfcDateValue(): IfcDateValue {\n return IfcDateValue.of(this.getDateAsString() + this.getTimeZoneAsString());\n }\n\n toIfcTimeValue(): IfcTimeValue {\n return IfcTimeValue.of(this.getTimeAsString() + this.getTimeZoneAsString());\n }\n\n toIfcTimeStampValue(): IfcTimeStampValue {\n return IfcTimeStampValue.of(this.getTimeStampSeconds());\n }\n\n addDuration(duration: IfcDurationValue): IfcDateTimeValue {\n const resultDate = new Date(this.utcDate.getTime());\n const accumulatedFractions = this.secondFraction.add(\n duration.getFractionAsSeconds()\n );\n const newSecondFraction = accumulatedFractions.minus(\n accumulatedFractions.divToInt(1)\n );\n resultDate.setUTCSeconds(\n resultDate.getUTCSeconds() + accumulatedFractions.divToInt(1).toNumber()\n );\n resultDate.setUTCSeconds(\n resultDate.getUTCSeconds() + duration.getSeconds().divToInt(1).toNumber()\n );\n resultDate.setUTCMinutes(\n resultDate.getUTCMinutes() + duration.getMinutes().divToInt(1).toNumber()\n );\n resultDate.setUTCHours(\n resultDate.getUTCHours() + duration.getHours().divToInt(1).toNumber()\n );\n resultDate.setUTCDate(\n resultDate.getUTCDate() + duration.getDays().divToInt(1).toNumber()\n );\n resultDate.setUTCDate(\n resultDate.getUTCDate() +\n duration.getWeeks().divToInt(1).times(7).toNumber()\n );\n resultDate.setUTCMonth(\n resultDate.getUTCMonth() + duration.getMonths().divToInt(1).toNumber()\n );\n resultDate.setUTCFullYear(\n resultDate.getUTCFullYear() + duration.getYears().divToInt(1).toNumber()\n );\n return new IfcDateTimeValue({\n utcDate: resultDate,\n secondFraction: newSecondFraction,\n originalTimeZoneHours: this.originalTimeZoneHours,\n originalTimeZoneMinutes: this.originalTimeZoneMinutes,\n isLocal: this.isLocal,\n });\n }\n}\n\nexport type ParsedIfcDateTimeValue = {\n utcDate: Date;\n secondFraction: Decimal;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n isLocal: boolean;\n};\n\nexport function isParsedIfcDateTimeValue(\n arg: any\n): arg is ParsedIfcDateTimeValue {\n return (\n !isNullish(arg.utcDate) &&\n !isNullish(arg.secondFraction) &&\n !isNullish(arg.originalTimeZoneHours) &&\n !isNullish(arg.originalTimeZoneMinutes) &&\n !isNullish(arg.isLocal)\n );\n}\n"]}
@@ -7,6 +7,7 @@ export class IfcDateValue {
7
7
  this.utcDateValue = parsed.utcDate;
8
8
  this.originalTimeZoneHours = parsed.originalTimeZoneHours;
9
9
  this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;
10
+ this.isLocal = parsed.isLocal;
10
11
  this.stringRepresentation = value;
11
12
  }
12
13
  static parseIfcDate(value) {
@@ -15,22 +16,28 @@ export class IfcDateValue {
15
16
  throw new DateFormatException("Not an IfcDate: " + value);
16
17
  }
17
18
  let [wholeString, year, month, day, timeZoneWhole, timeZoneSign, timeZoneHours, timeZoneMinutes,] = match;
18
- var utcDate = new Date(0);
19
+ const utcDate = new Date(0);
19
20
  utcDate.setUTCFullYear(Number.parseInt(year));
20
21
  utcDate.setUTCMonth(Number.parseInt(month) - 1);
21
22
  utcDate.setUTCDate(Number.parseInt(day));
22
- var originalZoneSign = isNullish(timeZoneSign)
23
+ const originalZoneSign = isNullish(timeZoneSign)
23
24
  ? 0
24
25
  : timeZoneSign === "+"
25
26
  ? -1
26
27
  : +1; //why? Beause +1 means 1 hour ahead of UTC, so we have to subtract 1 to get UTC
27
- var originalTimeZoneHours = originalZoneSign *
28
+ const originalTimeZoneHours = originalZoneSign *
28
29
  (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));
29
- var originalTimeZoneMinutes = originalZoneSign *
30
+ const originalTimeZoneMinutes = originalZoneSign *
30
31
  (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));
32
+ const isLocal = isNullish(timeZoneWhole);
31
33
  utcDate.setUTCHours(utcDate.getUTCHours() + originalTimeZoneHours);
32
34
  utcDate.setUTCMinutes(utcDate.getUTCMinutes() + originalTimeZoneMinutes);
33
- return { utcDate: utcDate, originalTimeZoneHours, originalTimeZoneMinutes };
35
+ return {
36
+ utcDate: utcDate,
37
+ originalTimeZoneHours,
38
+ originalTimeZoneMinutes,
39
+ isLocal,
40
+ };
34
41
  }
35
42
  static of(value) {
36
43
  return new IfcDateValue(value);
@@ -47,7 +54,7 @@ export class IfcDateValue {
47
54
  !isNullish(arg.stringRepresentation.match(IfcDateValue.regex))));
48
55
  }
49
56
  static isValidStringRepresentation(str) {
50
- return !isNullish(str.match(this.regex));
57
+ return this.regex.test(str);
51
58
  }
52
59
  equals(other) {
53
60
  return (IfcDateValue.isIfcDateValueType(other) &&
@@ -1 +1 @@
1
- {"version":3,"sources":["value/IfcDateValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,OAAO,YAAY;IAUvB,YAAY,KAAa;QACvB,IAAI,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;QAC1D,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QAC9D,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,KAAa;QAKtC,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;SAC3D;QACD,IAAI,CACF,WAAW,EACX,IAAI,EACJ,KAAK,EACL,GAAG,EACH,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EAChB,GAAG,KAAK,CAAC;QACV,IAAI,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ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,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAClE,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,2BAA2B,CAAC,GAAW;QACnD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAC7D,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACpE,CAAC;;AAvFuB,kBAAK,GAC3B,8HAA8H,CAAC","file":"value/IfcDateValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\n\nexport class IfcDateValue\n implements Value<IfcDateValue>, Comparable<IfcDateValue>\n{\n private readonly utcDateValue: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private static readonly regex =\n /^([+\\-]?(?:[1-9]\\d*)?\\d{4}(?<!0000))-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(value: string) {\n var parsed = IfcDateValue.parseIfcDate(value);\n this.utcDateValue = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDate(value: string): {\n utcDate: Date;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n } {\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDate: \" + value);\n }\n let [\n wholeString,\n year,\n month,\n day,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n var utcDate = new Date(0);\n utcDate.setUTCFullYear(Number.parseInt(year));\n utcDate.setUTCMonth(Number.parseInt(month) - 1);\n utcDate.setUTCDate(Number.parseInt(day));\n var originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? -1\n : +1; //why? Beause +1 means 1 hour ahead of UTC, so we have to subtract 1 to get UTC\n var originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n var originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n utcDate.setUTCHours(utcDate.getUTCHours() + originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() + originalTimeZoneMinutes);\n return { utcDate: utcDate, originalTimeZoneHours, originalTimeZoneMinutes };\n }\n\n public static of(value: string): IfcDateValue {\n return new IfcDateValue(value);\n }\n\n getValue(): IfcDateValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DATE;\n }\n\n static isIfcDateValueType(arg: any): arg is IfcDateValue {\n return (\n arg instanceof IfcDateValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDateValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return !isNullish(str.match(this.regex));\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDateValue.isIfcDateValueType(other) &&\n this.utcDateValue.getTime() === other.utcDateValue.getTime()\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDateValue): number {\n return this.utcDateValue.getTime() - other.utcDateValue.getTime();\n }\n}\n"]}
1
+ {"version":3,"sources":["value/IfcDateValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,MAAM,OAAO,YAAY;IAWvB,YAAY,KAAa;QACvB,IAAI,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;QAC1D,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,KAAa;QAMtC,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,MAAM,IAAI,mBAAmB,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;SAC3D;QACD,IAAI,CACF,WAAW,EACX,IAAI,EACJ,KAAK,EACL,GAAG,EACH,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EAChB,GAAG,KAAK,CAAC;QACV,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,OAAO,CAA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O,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,GAAQ;QAChC,OAAO,CACL,GAAG,YAAY,YAAY;YAC3B,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC;gBACnC,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAClE,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,2BAA2B,CAAC,GAAW;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,KAAiB;QACtB,OAAO,CACL,YAAY,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACtC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAC7D,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;IACpE,CAAC;;AA/FuB,kBAAK,GAC3B,8HAA8H,CAAC","file":"value/IfcDateValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\n\nexport class IfcDateValue\n implements Value<IfcDateValue>, Comparable<IfcDateValue>\n{\n private readonly utcDateValue: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private readonly isLocal: boolean;\n private static readonly regex =\n /^([+\\-]?(?:[1-9]\\d*)?\\d{4}(?<!0000))-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(value: string) {\n var parsed = IfcDateValue.parseIfcDate(value);\n this.utcDateValue = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.isLocal = parsed.isLocal;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDate(value: string): {\n utcDate: Date;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n isLocal: boolean;\n } {\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDate: \" + value);\n }\n let [\n wholeString,\n year,\n month,\n day,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n const utcDate = new Date(0);\n utcDate.setUTCFullYear(Number.parseInt(year));\n utcDate.setUTCMonth(Number.parseInt(month) - 1);\n utcDate.setUTCDate(Number.parseInt(day));\n const originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? -1\n : +1; //why? Beause +1 means 1 hour ahead of UTC, so we have to subtract 1 to get UTC\n const originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n const originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n const isLocal = isNullish(timeZoneWhole);\n utcDate.setUTCHours(utcDate.getUTCHours() + originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() + originalTimeZoneMinutes);\n return {\n utcDate: utcDate,\n originalTimeZoneHours,\n originalTimeZoneMinutes,\n isLocal,\n };\n }\n\n public static of(value: string): IfcDateValue {\n return new IfcDateValue(value);\n }\n\n getValue(): IfcDateValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DATE;\n }\n\n static isIfcDateValueType(arg: any): arg is IfcDateValue {\n return (\n arg instanceof IfcDateValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDateValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return this.regex.test(str);\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDateValue.isIfcDateValueType(other) &&\n this.utcDateValue.getTime() === other.utcDateValue.getTime()\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDateValue): number {\n return this.utcDateValue.getTime() - other.utcDateValue.getTime();\n }\n}\n"]}
@@ -91,7 +91,7 @@ export class IfcDurationValue {
91
91
  !isNullish(arg.totalSeconds)));
92
92
  }
93
93
  static isValidStringRepresentation(str) {
94
- return !isNullish(str.match(this.regex));
94
+ return this.regex.test(str);
95
95
  }
96
96
  equals(other) {
97
97
  return (IfcDurationValue.isIfcDurationValueType(other) &&
@@ -1 +1 @@
1
- {"version":3,"sources":["value/IfcDurationValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAO,gBAAgB;IAuB3B,YAAY,KAAa;QACvB,MAAM,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,YAAY,GACb,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GA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ourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\n\nexport class IfcDurationValue\n implements Value<IfcDurationValue>, Comparable<IfcDurationValue>\n{\n private readonly stringRepresentation;\n private static readonly MINUTE = new Decimal(60);\n private static readonly HOUR = IfcDurationValue.MINUTE.mul(60);\n private static readonly DAY = IfcDurationValue.HOUR.mul(24);\n private static readonly WEEK = IfcDurationValue.DAY.mul(7);\n private static readonly YEAR = new Decimal(31557600);\n private static readonly MONTH = IfcDurationValue.YEAR.div(12);\n private readonly years: Decimal;\n private readonly months: Decimal;\n private readonly weeks: Decimal;\n private readonly days: Decimal;\n private readonly hours: Decimal;\n private readonly minutes: Decimal;\n private readonly seconds: Decimal;\n private readonly fractionAsSeconds: Decimal;\n private readonly totalSeconds: Decimal;\n\n private static readonly regex =\n /^P(?!$)(?:(\\d+(?:\\.\\d+(?=Y$))?)Y)?(?:(\\d+(?:\\.\\d+(?=M$))?)M)?(?:(\\d+(?:\\.\\d+(?=W$))?)W)?(?:(\\d+(?:\\.\\d+(?=D$))?)D)?(?:T(?!$)(?:(\\d+(?:\\.\\d+(?=H$))?)H)?(?:(\\d+(?:\\.\\d+(?=M$))?)M)?(?:(\\d+(?:\\.\\d+(?=S$))?)S)?)?$/;\n\n constructor(value: string) {\n const {\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds,\n fractionAsSeconds,\n totalSeconds,\n } = IfcDurationValue.parseIfcDuration(value);\n this.years = years;\n this.months = months;\n this.weeks = weeks;\n this.days = days;\n this.hours = hours;\n this.minutes = minutes;\n this.seconds = seconds;\n this.totalSeconds = totalSeconds;\n this.fractionAsSeconds = fractionAsSeconds;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDuration(value: string): {\n years: Decimal;\n months: Decimal;\n weeks: Decimal;\n days: Decimal;\n hours: Decimal;\n minutes: Decimal;\n seconds: Decimal;\n fractionAsSeconds: Decimal;\n totalSeconds: Decimal;\n } {\n Decimal.set({ defaults: true });\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDateTime: \" + value);\n }\n let [\n wholeString,\n yearsVal,\n monthsVal,\n weeksVal,\n daysVal,\n hoursVal,\n minutesVal,\n secondsVal,\n ] = match;\n var years = new Decimal(isNullish(yearsVal) ? \"0\" : yearsVal);\n var months = new Decimal(isNullish(monthsVal) ? \"0\" : monthsVal);\n var weeks = new Decimal(isNullish(weeksVal) ? \"0\" : weeksVal);\n var days = new Decimal(isNullish(daysVal) ? \"0\" : daysVal);\n var hours = new Decimal(isNullish(hoursVal) ? \"0\" : hoursVal);\n var minutes = new Decimal(isNullish(minutesVal) ? \"0\" : minutesVal);\n var seconds = new Decimal(isNullish(secondsVal) ? \"0\" : secondsVal);\n var fractionAsSeconds = IfcDurationValue.getFractionAsSeconds(\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds\n );\n var totalSeconds = years\n .mul(IfcDurationValue.YEAR)\n .plus(months.mul(IfcDurationValue.MONTH))\n .plus(weeks.mul(IfcDurationValue.WEEK))\n .plus(days.mul(IfcDurationValue.DAY))\n .plus(hours.mul(IfcDurationValue.HOUR))\n .plus(minutes.mul(IfcDurationValue.MINUTE))\n .plus(seconds);\n return {\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds,\n fractionAsSeconds,\n totalSeconds,\n };\n }\n\n private static getFractionAsSeconds(\n years: Decimal,\n months: Decimal,\n weeks: Decimal,\n days: Decimal,\n hours: Decimal,\n minutes: Decimal,\n seconds: Decimal\n ) {\n if (!seconds.isZero() && !seconds.isInteger()) {\n return seconds.minus(seconds.divToInt(1));\n }\n if (!minutes.isZero() && !minutes.isInteger()) {\n return minutes.minus(minutes.divToInt(1)).times(IfcDurationValue.MINUTE);\n }\n if (!hours.isZero() && !hours.isInteger()) {\n return hours.minus(hours.divToInt(1)).times(IfcDurationValue.HOUR);\n }\n if (!days.isZero() && !days.isInteger()) {\n return days.minus(days.divToInt(1)).times(IfcDurationValue.DAY);\n }\n if (!weeks.isZero() && !weeks.isInteger()) {\n return weeks.minus(weeks.divToInt(1)).times(IfcDurationValue.WEEK);\n }\n if (!months.isZero() && !months.isInteger()) {\n return months.minus(months.divToInt(1)).times(IfcDurationValue.MONTH);\n }\n if (!years.isZero() && !years.isInteger()) {\n return years.minus(years.divToInt(1)).times(IfcDurationValue.YEAR);\n }\n return new Decimal(0);\n }\n\n public static of(value: string): IfcDurationValue {\n return new IfcDurationValue(value);\n }\n\n getValue(): IfcDurationValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DURATION;\n }\n\n static isIfcDurationValueType(arg: any): arg is IfcDurationValue {\n return (\n arg instanceof IfcDurationValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDurationValue.regex)) &&\n !isNullish(arg.totalSeconds))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return !isNullish(str.match(this.regex));\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDurationValue.isIfcDurationValueType(other) &&\n this.totalSeconds.eq(other.totalSeconds)\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDurationValue): number {\n var diff = this.totalSeconds.minus(other.totalSeconds);\n return Decimal.sign(diff);\n }\n\n getYears() {\n return this.years;\n }\n getMonths() {\n return this.months;\n }\n getWeeks() {\n return this.weeks;\n }\n getDays() {\n return this.days;\n }\n getHours() {\n return this.hours;\n }\n getMinutes() {\n return this.minutes;\n }\n getSeconds() {\n return this.seconds;\n }\n getTotalSeconds() {\n return this.totalSeconds;\n }\n getFractionAsSeconds() {\n return this.fractionAsSeconds;\n }\n}\n"]}
1
+ {"version":3,"sources":["value/IfcDurationValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE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C,CAAC;;AA9MuB,uBAAM,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;AACzB,qBAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACvC,oBAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpC,qBAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnC,qBAAI,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC7B,sBAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAWtC,sBAAK,GAC3B,kNAAkN,CAAC","file":"value/IfcDurationValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\n\nexport class IfcDurationValue\n implements Value<IfcDurationValue>, Comparable<IfcDurationValue>\n{\n private readonly stringRepresentation;\n private static readonly MINUTE = new Decimal(60);\n private static readonly HOUR = IfcDurationValue.MINUTE.mul(60);\n private static readonly DAY = IfcDurationValue.HOUR.mul(24);\n private static readonly WEEK = IfcDurationValue.DAY.mul(7);\n private static readonly YEAR = new Decimal(31557600);\n private static readonly MONTH = IfcDurationValue.YEAR.div(12);\n private readonly years: Decimal;\n private readonly months: Decimal;\n private readonly weeks: Decimal;\n private readonly days: Decimal;\n private readonly hours: Decimal;\n private readonly minutes: Decimal;\n private readonly seconds: Decimal;\n private readonly fractionAsSeconds: Decimal;\n private readonly totalSeconds: Decimal;\n\n private static readonly regex =\n /^P(?!$)(?:(\\d+(?:\\.\\d+(?=Y$))?)Y)?(?:(\\d+(?:\\.\\d+(?=M$))?)M)?(?:(\\d+(?:\\.\\d+(?=W$))?)W)?(?:(\\d+(?:\\.\\d+(?=D$))?)D)?(?:T(?!$)(?:(\\d+(?:\\.\\d+(?=H$))?)H)?(?:(\\d+(?:\\.\\d+(?=M$))?)M)?(?:(\\d+(?:\\.\\d+(?=S$))?)S)?)?$/;\n\n constructor(value: string) {\n const {\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds,\n fractionAsSeconds,\n totalSeconds,\n } = IfcDurationValue.parseIfcDuration(value);\n this.years = years;\n this.months = months;\n this.weeks = weeks;\n this.days = days;\n this.hours = hours;\n this.minutes = minutes;\n this.seconds = seconds;\n this.totalSeconds = totalSeconds;\n this.fractionAsSeconds = fractionAsSeconds;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDuration(value: string): {\n years: Decimal;\n months: Decimal;\n weeks: Decimal;\n days: Decimal;\n hours: Decimal;\n minutes: Decimal;\n seconds: Decimal;\n fractionAsSeconds: Decimal;\n totalSeconds: Decimal;\n } {\n Decimal.set({ defaults: true });\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcDateTime: \" + value);\n }\n let [\n wholeString,\n yearsVal,\n monthsVal,\n weeksVal,\n daysVal,\n hoursVal,\n minutesVal,\n secondsVal,\n ] = match;\n var years = new Decimal(isNullish(yearsVal) ? \"0\" : yearsVal);\n var months = new Decimal(isNullish(monthsVal) ? \"0\" : monthsVal);\n var weeks = new Decimal(isNullish(weeksVal) ? \"0\" : weeksVal);\n var days = new Decimal(isNullish(daysVal) ? \"0\" : daysVal);\n var hours = new Decimal(isNullish(hoursVal) ? \"0\" : hoursVal);\n var minutes = new Decimal(isNullish(minutesVal) ? \"0\" : minutesVal);\n var seconds = new Decimal(isNullish(secondsVal) ? \"0\" : secondsVal);\n var fractionAsSeconds = IfcDurationValue.getFractionAsSeconds(\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds\n );\n var totalSeconds = years\n .mul(IfcDurationValue.YEAR)\n .plus(months.mul(IfcDurationValue.MONTH))\n .plus(weeks.mul(IfcDurationValue.WEEK))\n .plus(days.mul(IfcDurationValue.DAY))\n .plus(hours.mul(IfcDurationValue.HOUR))\n .plus(minutes.mul(IfcDurationValue.MINUTE))\n .plus(seconds);\n return {\n years,\n months,\n weeks,\n days,\n hours,\n minutes,\n seconds,\n fractionAsSeconds,\n totalSeconds,\n };\n }\n\n private static getFractionAsSeconds(\n years: Decimal,\n months: Decimal,\n weeks: Decimal,\n days: Decimal,\n hours: Decimal,\n minutes: Decimal,\n seconds: Decimal\n ) {\n if (!seconds.isZero() && !seconds.isInteger()) {\n return seconds.minus(seconds.divToInt(1));\n }\n if (!minutes.isZero() && !minutes.isInteger()) {\n return minutes.minus(minutes.divToInt(1)).times(IfcDurationValue.MINUTE);\n }\n if (!hours.isZero() && !hours.isInteger()) {\n return hours.minus(hours.divToInt(1)).times(IfcDurationValue.HOUR);\n }\n if (!days.isZero() && !days.isInteger()) {\n return days.minus(days.divToInt(1)).times(IfcDurationValue.DAY);\n }\n if (!weeks.isZero() && !weeks.isInteger()) {\n return weeks.minus(weeks.divToInt(1)).times(IfcDurationValue.WEEK);\n }\n if (!months.isZero() && !months.isInteger()) {\n return months.minus(months.divToInt(1)).times(IfcDurationValue.MONTH);\n }\n if (!years.isZero() && !years.isInteger()) {\n return years.minus(years.divToInt(1)).times(IfcDurationValue.YEAR);\n }\n return new Decimal(0);\n }\n\n public static of(value: string): IfcDurationValue {\n return new IfcDurationValue(value);\n }\n\n getValue(): IfcDurationValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_DURATION;\n }\n\n static isIfcDurationValueType(arg: any): arg is IfcDurationValue {\n return (\n arg instanceof IfcDurationValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcDurationValue.regex)) &&\n !isNullish(arg.totalSeconds))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return this.regex.test(str);\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcDurationValue.isIfcDurationValueType(other) &&\n this.totalSeconds.eq(other.totalSeconds)\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcDurationValue): number {\n var diff = this.totalSeconds.minus(other.totalSeconds);\n return Decimal.sign(diff);\n }\n\n getYears() {\n return this.years;\n }\n getMonths() {\n return this.months;\n }\n getWeeks() {\n return this.weeks;\n }\n getDays() {\n return this.days;\n }\n getHours() {\n return this.hours;\n }\n getMinutes() {\n return this.minutes;\n }\n getSeconds() {\n return this.seconds;\n }\n getTotalSeconds() {\n return this.totalSeconds;\n }\n getFractionAsSeconds() {\n return this.fractionAsSeconds;\n }\n}\n"]}
@@ -9,6 +9,7 @@ export class IfcTimeValue {
9
9
  this.originalTimeZoneHours = parsed.originalTimeZoneHours;
10
10
  this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;
11
11
  this.secondFraction = parsed.secondFraction;
12
+ this.isLocal = parsed.isLocal;
12
13
  this.stringRepresentation = value;
13
14
  }
14
15
  static parseIfcDate(value) {
@@ -17,22 +18,23 @@ export class IfcTimeValue {
17
18
  throw new DateFormatException("Not an IfcTime: " + value);
18
19
  }
19
20
  let [wholeString, hours, minutes, seconds, fractionSeconds, timeZoneWhole, timeZoneSign, timeZoneHours, timeZoneMinutes,] = match;
20
- var utcDate = new Date(0);
21
+ const utcDate = new Date(0);
21
22
  utcDate.setUTCHours(Number.parseInt(hours));
22
23
  utcDate.setUTCMinutes(Number.parseInt(minutes));
23
24
  utcDate.setUTCSeconds(Number.parseInt(seconds));
24
- var secondFraction = isNullish(fractionSeconds)
25
+ const secondFraction = isNullish(fractionSeconds)
25
26
  ? new Decimal("0")
26
27
  : new Decimal("0" + fractionSeconds); //arbitrary precision fractions
27
- var originalZoneSign = isNullish(timeZoneSign)
28
+ const originalZoneSign = isNullish(timeZoneSign)
28
29
  ? 0
29
30
  : timeZoneSign === "+"
30
31
  ? 1
31
32
  : -1;
32
- var originalTimeZoneHours = originalZoneSign *
33
+ const originalTimeZoneHours = originalZoneSign *
33
34
  (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));
34
- var originalTimeZoneMinutes = originalZoneSign *
35
+ const originalTimeZoneMinutes = originalZoneSign *
35
36
  (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));
37
+ const isLocal = isNullish(timeZoneWhole);
36
38
  utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);
37
39
  utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);
38
40
  return {
@@ -40,6 +42,7 @@ export class IfcTimeValue {
40
42
  secondFraction,
41
43
  originalTimeZoneHours,
42
44
  originalTimeZoneMinutes,
45
+ isLocal,
43
46
  };
44
47
  }
45
48
  static of(value) {
@@ -57,7 +60,7 @@ export class IfcTimeValue {
57
60
  !isNullish(arg.stringRepresentation.match(IfcTimeValue.regex))));
58
61
  }
59
62
  static isValidStringRepresentation(str) {
60
- return !isNullish(str.match(this.regex));
63
+ return this.regex.test(str);
61
64
  }
62
65
  equals(other) {
63
66
  return (IfcTimeValue.isIfcTimeValueType(other) &&
@@ -1 +1 @@
1
- {"version":3,"sources":["value/IfcTimeValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAO,YAAY;IAWvB,YAAY,KAAa;QACvB,IAAI,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;QAC1D,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QA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IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAC7C,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QACtE,IAAI,IAAI,IAAI,CAAC,EAAE;YACb,OAAO,IAAI,CAAC;SACb;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,OAAO,CAAC,CAAC;SACV;QACD,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACf,OAAO,CAAC,CAAC,CAAC;SACX;QACD,OAAO,CAAC,CAAC;IACX,CAAC;;AA9GuB,kBAAK,GAC3B,oHAAoH,CAAC","file":"value/IfcTimeValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\n\nexport class IfcTimeValue\n implements Value<IfcTimeValue>, Comparable<IfcTimeValue>\n{\n private readonly utcDateValue: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private readonly secondFraction: Decimal;\n private static readonly regex =\n /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|(?<=23:59:)60)(\\.\\d+)?(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(value: string) {\n var parsed = IfcTimeValue.parseIfcDate(value);\n this.utcDateValue = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.secondFraction = parsed.secondFraction;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDate(value: string): {\n utcDate: Date;\n secondFraction: Decimal;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n } {\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcTime: \" + value);\n }\n let [\n wholeString,\n hours,\n minutes,\n seconds,\n fractionSeconds,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n var utcDate = new Date(0);\n utcDate.setUTCHours(Number.parseInt(hours));\n utcDate.setUTCMinutes(Number.parseInt(minutes));\n utcDate.setUTCSeconds(Number.parseInt(seconds));\n var secondFraction = isNullish(fractionSeconds)\n ? new Decimal(\"0\")\n : new Decimal(\"0\" + fractionSeconds); //arbitrary precision fractions\n var originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? 1\n : -1;\n var originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n var originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);\n return {\n utcDate,\n secondFraction,\n originalTimeZoneHours,\n originalTimeZoneMinutes,\n };\n }\n\n public static of(value: string): IfcTimeValue {\n return new IfcTimeValue(value);\n }\n\n getValue(): IfcTimeValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_TIME;\n }\n\n static isIfcTimeValueType(arg: any): arg is IfcTimeValue {\n return (\n arg instanceof IfcTimeValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcTimeValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return !isNullish(str.match(this.regex));\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcTimeValue.isIfcTimeValueType(other) &&\n this.utcDateValue.getTime() === other.utcDateValue.getTime() &&\n this.secondFraction.eq(other.secondFraction)\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcTimeValue): number {\n var diff = this.utcDateValue.getTime() - other.utcDateValue.getTime();\n if (diff != 0) {\n return diff;\n }\n var diffD = this.secondFraction.minus(other.secondFraction);\n if (diffD.isZero()) {\n return 0;\n }\n if (diffD.lt(0)) {\n return -1;\n }\n return 1;\n }\n}\n"]}
1
+ {"version":3,"sources":["value/IfcTimeValue.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,MAAM,OAAO,YAAY;IAavB,YAAY,KAAa;QACvB,IAAI,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC;QAC1D,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QAC9D,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACpC,CAAC;IAEM,MAAM,CAAC,YAAY,CAAC,KAAa;QAOtC,IAA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AAC,oBAAoB,CAAC;IACnC,CAAC;IAED,SAAS,CAAC,KAAmB;QAC3B,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QACtE,IAAI,IAAI,IAAI,CAAC,EAAE;YACb,OAAO,IAAI,CAAC;SACb;QACD,IAAI,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC5D,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAClB,OAAO,CAAC,CAAC;SACV;QACD,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;YACf,OAAO,CAAC,CAAC,CAAC;SACX;QACD,OAAO,CAAC,CAAC;IACX,CAAC;;AAlHuB,kBAAK,GAC3B,oHAAoH,CAAC","file":"value/IfcTimeValue.js","sourcesContent":["import { Value } from \"./Value.js\";\nimport { Comparable } from \"./Comparable.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { Type } from \"../type/Types.js\";\nimport { isNullish } from \"../util/IfcExpressionUtils.js\";\nimport { DateFormatException } from \"../error/value/DateFormatException.js\";\nimport Decimal from \"decimal.js\";\n\nexport class IfcTimeValue\n implements Value<IfcTimeValue>, Comparable<IfcTimeValue>\n{\n private readonly utcDateValue: Date;\n private readonly stringRepresentation;\n private readonly originalTimeZoneHours: number; // hours ahead of (+) or behind (-) UTC\n private readonly originalTimeZoneMinutes: number; // minutes ahead of (+) or behind (-) UTC\n private readonly isLocal: boolean;\n private readonly secondFraction: Decimal;\n\n private static readonly regex =\n /^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|(?<=23:59:)60)(\\.\\d+)?(Z|([+\\-])(0[0-9]|1[0-2])(?::?([0-5][0-9]))?)?$/;\n\n constructor(value: string) {\n var parsed = IfcTimeValue.parseIfcDate(value);\n this.utcDateValue = parsed.utcDate;\n this.originalTimeZoneHours = parsed.originalTimeZoneHours;\n this.originalTimeZoneMinutes = parsed.originalTimeZoneMinutes;\n this.secondFraction = parsed.secondFraction;\n this.isLocal = parsed.isLocal;\n this.stringRepresentation = value;\n }\n\n public static parseIfcDate(value: string): {\n utcDate: Date;\n secondFraction: Decimal;\n originalTimeZoneHours?: number;\n originalTimeZoneMinutes?: number;\n isLocal: boolean;\n } {\n let match = value.match(this.regex);\n if (isNullish(match)) {\n throw new DateFormatException(\"Not an IfcTime: \" + value);\n }\n let [\n wholeString,\n hours,\n minutes,\n seconds,\n fractionSeconds,\n timeZoneWhole,\n timeZoneSign,\n timeZoneHours,\n timeZoneMinutes,\n ] = match;\n const utcDate = new Date(0);\n utcDate.setUTCHours(Number.parseInt(hours));\n utcDate.setUTCMinutes(Number.parseInt(minutes));\n utcDate.setUTCSeconds(Number.parseInt(seconds));\n const secondFraction = isNullish(fractionSeconds)\n ? new Decimal(\"0\")\n : new Decimal(\"0\" + fractionSeconds); //arbitrary precision fractions\n const originalZoneSign = isNullish(timeZoneSign)\n ? 0\n : timeZoneSign === \"+\"\n ? 1\n : -1;\n const originalTimeZoneHours =\n originalZoneSign *\n (isNullish(timeZoneHours) ? 0 : Number.parseInt(timeZoneHours));\n const originalTimeZoneMinutes =\n originalZoneSign *\n (isNullish(timeZoneMinutes) ? 0 : Number.parseInt(timeZoneMinutes));\n const isLocal = isNullish(timeZoneWhole);\n utcDate.setUTCHours(utcDate.getUTCHours() - originalTimeZoneHours);\n utcDate.setUTCMinutes(utcDate.getUTCMinutes() - originalTimeZoneMinutes);\n return {\n utcDate,\n secondFraction,\n originalTimeZoneHours,\n originalTimeZoneMinutes,\n isLocal,\n };\n }\n\n public static of(value: string): IfcTimeValue {\n return new IfcTimeValue(value);\n }\n\n getValue(): IfcTimeValue {\n return this;\n }\n\n getType(): ExprType {\n return Type.IFC_TIME;\n }\n\n static isIfcTimeValueType(arg: any): arg is IfcTimeValue {\n return (\n arg instanceof IfcTimeValue ||\n (!isNullish(arg.stringRepresentation) &&\n !isNullish(arg.stringRepresentation.match(IfcTimeValue.regex)))\n );\n }\n\n public static isValidStringRepresentation(str: string): boolean {\n return this.regex.test(str);\n }\n\n equals(other: Value<any>): boolean {\n return (\n IfcTimeValue.isIfcTimeValueType(other) &&\n this.utcDateValue.getTime() === other.utcDateValue.getTime() &&\n this.secondFraction.eq(other.secondFraction)\n );\n }\n\n toString(): string {\n return this.stringRepresentation;\n }\n\n compareTo(other: IfcTimeValue): number {\n var diff = this.utcDateValue.getTime() - other.utcDateValue.getTime();\n if (diff != 0) {\n return diff;\n }\n var diffD = this.secondFraction.minus(other.secondFraction);\n if (diffD.isZero()) {\n return 0;\n }\n if (diffD.lt(0)) {\n return -1;\n }\n return 1;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { NonBoxedValueTypes } from \"./NonBoxedValueTypes.js\";\n\nexport interface Value<\n T extends\n | NonBoxedValueTypes\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n getType(): ExprType;\n}\n"]}
1
+ {"version":3,"sources":["value/Value.ts"],"names":[],"mappings":"","file":"value/Value.js","sourcesContent":["import { BoxedValueTypes } from \"./BoxedValueTypes.js\";\nimport { ExprType } from \"../type/ExprType.js\";\nimport { ValueType } from \"./ValueType\";\n\nexport interface Value<\n T extends\n | ValueType\n | BoxedValueTypes\n | Array<Value<BoxedValueTypes | Array<Value<BoxedValueTypes>>>>\n> {\n getValue(): T;\n equals(other: Value<any>): boolean;\n toString();\n getType(): ExprType;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ValueType.js.map