UNPKG

@head.js/analytics.js-new-date

Version:

Creates a new Date, but accepts a few more input types than normal.

29 lines (24 loc) 440 B
"use strict"; /** * Matcher. */ var matcher = /\d{13}/; /** * Check whether a string is a millisecond date string. * * @param {string} string * @return {boolean} */ exports.is = function (string) { return matcher.test(string); }; /** * Convert a millisecond string to a date. * * @param {string} millis * @return {Date} */ exports.parse = function (millis) { millis = parseInt(millis, 10); return new Date(millis); };