How to use the chrono-node.Chrono function in chrono-node

To help you get started, we’ve selected a few chrono-node 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 unscrollinc / unscroll / client / src / components / Timeline / EventInput.js View on Github external
};
PositiveParser.extract = function(text, ref, match, opt) {
    console.log({ text: text, ref: ref, match: match, opt: opt });
    let pr = new chrono.ParsedResult({
        ref: ref,
        text: match[0],
        index: match.index,
        start: {
            year: parseInt(match[0], 10)
        }
    });
    const x = implyLateStart(pr);
    return x;
};

var custom = new en.Chrono();
custom.parsers.push(BCParser);
custom.parsers.push(NegativeParser);
custom.parsers.push(CenturyParser);
custom.parsers.push(PositiveParser);

class Timelist extends React.Component {
    constructor(props) {
        super(props);
        // update is a function that grabs the state
        this.editSeveral = props.editSeveral;

        this.state = {
            when_original: null,
            when_happened: null,
            resolution: null,
            parsed: null,
github bdm1981 / roomRequest-Spark-Bot / module / timeNLP.js View on Github external
result.start.assign('meridiem', 1);
            result.start.assign('hour', result.start.get('hour') + 12);
        }
        if (result.end && !result.end.isCertain('meridiem')
            &&  result.end.get('hour') >= 1 && result.end.get('hour') < 6) {

            result.end.assign('meridiem', 1);
            result.end.assign('hour', result.end.get('hour') + 12);
        }
    });
    return results;
};
// Create a new custom Chrono. The initial pipeline 'option' can also be specified as
// - new chrono.Chrono(exports.options.strictOption())
// - new chrono.Chrono(exports.options.casualOption())
var custom = new chrono.Chrono();
custom.refiners.push(guessPMRefiner);
github bkeepers / parse-reminder / index.js View on Github external
const chrono = require('chrono-node')

const matcher = /^remind @?([^\s]+)(?: to )?(.*)$/

const parser = new chrono.Chrono()
parser.refiners.push(require('./lib/refiners/start-of-day'))

const options = {
  forwardDate: true,
  startOfDay: 9
}

module.exports = (input, from) => {
  const match = input.match(matcher)
  if (!match) {
    // This doesn't look like a reminder, so bail early
    return null
  }

  // Pull out the initial matches
  let [, who, what] = match

chrono-node

A natural language date parser in Javascript

MIT
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis

Similar packages