How to use the date-format.parse function in date-format

To help you get started, we’ve selected a few date-format 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 log4js-node / streamroller / lib / fileNameParser.js View on Github external
if (indexStr !== undefined && indexStr.match(/^\d+$/)) {
      dateStr = f.slice(0, -1 * (indexStr.length + 1));
      debug(`dateStr is ${dateStr}`);
      if (pattern && !dateStr) {
        dateStr = indexStr;
        indexStr = "0";
      }
    } else {
      indexStr = "0";
    }

    try {
      // Two arguments for new Date() are intentional. This will set other date
      // components to minimal values in the current timezone instead of UTC,
      // as new Date(0) will do.
      const date = format.parse(pattern, dateStr, new Date(0, 0));
      p.index = parseInt(indexStr, 10);
      p.date = dateStr;
      p.timestamp = date.getTime();
      return "";
    } catch (e) {
      //not a valid date, don't panic.
      debug(`Problem parsing ${dateStr} as ${pattern}, error was: `, e);
      return f;
    }
  };
github publiclab / Leaflet.DistortableImage / node_modules / streamroller / lib / RollingFileWriteStream.js View on Github external
n =>
            (n.date
              ? format.parse(this.options.pattern, n.date).valueOf()
              : newNow().valueOf()) - n.index
        )

date-format

Formatting Date objects as strings since 2013

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis