moment-parseformat
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -51,2 +51,10 @@ /* istanbul ignore next */ | ||
var regexDayShortMonthShort = /^([1-9])\/([1-9]|0[1-9])$/ | ||
var regexDayShortMonth = /^([1-9])\/(1[012])$/ | ||
var regexDayMonthShort = /^(0[1-9]|[12][0-9]|3[01])\/([1-9])$/ | ||
var regexDayMonth = /^(0[1-9]|[12][0-9]|3[01])\/(1[012]|0[1-9])$/ | ||
var regexMonthShortYearShort = /^([1-9])\/([1-9][0-9])$/ | ||
var regexMonthYearShort = /^(0[1-9]|1[012])\/([1-9][0-9])$/ | ||
var regexFillingWords = /\b(at)\b/i | ||
@@ -140,2 +148,20 @@ | ||
// check if both numbers are < 13, then it must be D/M | ||
format = format.replace(regexDayShortMonthShort, 'D/M') | ||
// check if first number is < 10 && last < 13, then it must be D/MM | ||
format = format.replace(regexDayShortMonth, 'D/MM') | ||
// check if last number is < 32 && last < 10, then it must be DD/M | ||
format = format.replace(regexDayMonthShort, 'DD/M') | ||
// check if both numbers are > 10, but first < 32 && last < 13, then it must be DD/MM | ||
format = format.replace(regexDayMonth, 'DD/MM') | ||
// check if first < 10 && last > 12, then it must be M/YY | ||
format = format.replace(regexMonthShortYearShort, 'M/YY') | ||
// check if first < 13 && last > 12, then it must be MM/YY | ||
format = format.replace(regexMonthYearShort, 'MM/YY') | ||
// now, the next number, if existing, must be a day | ||
@@ -142,0 +168,0 @@ format = format.replace(regexDayLeadingZero, 'DD') |
@@ -41,3 +41,3 @@ { | ||
}, | ||
"version": "1.1.1" | ||
"version": "1.1.2" | ||
} |
@@ -11,2 +11,4 @@ moment.parseFormat – a moment.js plugin | ||
[![Coverage Status](https://coveralls.io/repos/gr2m/moment.parseFormat/badge.svg?branch=&service=github)](https://coveralls.io/github/gr2m/moment.parseFormat?branch=gh-pages) | ||
Installation | ||
@@ -13,0 +15,0 @@ ------------ |
@@ -55,6 +55,24 @@ 'use strict' | ||
// https://github.com/gr2m/moment.parseFormat/pull/29 | ||
t.equal(moment.parseFormat('1434575583'), 'X', '1434575583 → X') | ||
t.equal(moment.parseFormat('1318781876406'), 'x', '1318781876406 → x') | ||
t.equal(moment.parseFormat('1434575583'), 'X', '1434575583 → X') | ||
t.equal(moment.parseFormat('1318781876406'), 'x', '1318781876406 → x') | ||
t.end() | ||
}) | ||
test('GitHub issues - special cases', function (t) { | ||
// https://github.com/gr2m/moment-parseformat/issues/17 | ||
t.equal(moment.parseFormat('3/15'), 'M/YY', 'last number is > 12 - 3/15 → M/Y') | ||
t.equal(moment.parseFormat('03/15'), 'MM/YY', 'last number is > 12 - 03/15 → MM/Y') | ||
t.equal(moment.parseFormat('11/15'), 'MM/YY', 'last number is > 12 - 11/15 → MM/Y') | ||
t.equal(moment.parseFormat('15/3'), 'DD/M', 'first number is > 12 - 15/3 → DD/M') | ||
t.equal(moment.parseFormat('03/12'), 'DD/MM', 'both numbers are < 13 - 03/12 → DD/MM') | ||
t.equal(moment.parseFormat('3/3'), 'D/M', 'both numbers are < 13 - 3/3 → D/M') | ||
t.equal(moment.parseFormat('13/2'), 'DD/M', 'first number is > 12 && <= 31 - 13/2 → DD/M') | ||
t.equal(moment.parseFormat('03/12'), 'DD/MM', 'both numbers are < 13 - 03/12 → DD/MM') | ||
t.equal(moment.parseFormat('03/03'), 'DD/MM', 'both numbers are < 13 - 03/03 → DD/MM') | ||
t.equal(moment.parseFormat('13/02'), 'DD/MM', 'first number is > 12 && <= 31 - 13/02 → DD/MM') | ||
t.equal(moment.parseFormat('3/12'), 'D/MM', 'both numbers are < 13 - 3/12 → D/MM') | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22719
249
111