How to use the @accordproject/ergo-compiler.Util.setCurrentTime function in @accordproject/ergo-compiler

To help you get started, we’ve selected a few @accordproject/ergo-compiler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accordproject / cicero / packages / cicero-core / src / templateinstance.js View on Github external
parse(input, currentTime, fileName) {
        let text = TemplateLoader.normalizeText(input);
        // Roundtrip the sample through the Commonmark parser
        text = this.getTemplate().getParserManager().roundtripMarkdown(text);

        // Set the current time and UTC Offset
        const now = Util.setCurrentTime(currentTime);
        const utcOffset = now.utcOffset();

        let parser = this.getTemplate().getParserManager().getParser();
        try {
            parser.feed(text);
        } catch(err) {
            const fileLocation = ErrorUtil.locationOfError(err);
            throw new ParseException(err.message, fileLocation, fileName, err.message, 'cicero-core');
        }
        if (parser.results.length !== 1) {
            const head = JSON.stringify(parser.results[0]);

            parser.results.forEach(function (element) {
                if (head !== JSON.stringify(element)) {
                    const err = `Ambiguous text. Got ${parser.results.length} ASTs for text: ${text}`;
                    throw new ParseException(err, null, fileName, err, 'cicero-core' );