浏览代码

fix datetime alias date parsing

Robin Herbots 8 年之前
父节点
当前提交
3fd6b41a1d
共有 49 个文件被更改,包括 107 次插入100 次删除
  1. 1 1
      README.md
  2. 1 1
      bower.json
  3. 1 1
      component.json
  4. 1 1
      composer.json
  5. 2 2
      dist/inputmask/bindings/inputmask.binding.js
  6. 2 2
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js
  7. 2 2
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js
  8. 2 2
      dist/inputmask/dependencyLibs/inputmask.dependencyLib.js
  9. 2 2
      dist/inputmask/global/document.js
  10. 2 2
      dist/inputmask/global/window.js
  11. 3 3
      dist/inputmask/inputmask.date.extensions.js
  12. 2 2
      dist/inputmask/inputmask.extensions.js
  13. 2 2
      dist/inputmask/inputmask.js
  14. 2 2
      dist/inputmask/inputmask.numeric.extensions.js
  15. 2 2
      dist/inputmask/inputmask.phone.extensions.js
  16. 2 2
      dist/inputmask/jquery.inputmask.js
  17. 2 2
      dist/inputmask/phone-codes/phone-be.js
  18. 2 2
      dist/inputmask/phone-codes/phone-ca.js
  19. 2 2
      dist/inputmask/phone-codes/phone-mx.js
  20. 2 2
      dist/inputmask/phone-codes/phone-nl.js
  21. 2 2
      dist/inputmask/phone-codes/phone-ru.js
  22. 2 2
      dist/inputmask/phone-codes/phone-uk.js
  23. 2 2
      dist/inputmask/phone-codes/phone-us.js
  24. 2 2
      dist/inputmask/phone-codes/phone.js
  25. 4 4
      dist/jquery.inputmask.bundle.js
  26. 2 2
      dist/min/inputmask/bindings/inputmask.binding.min.js
  27. 2 2
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js
  28. 2 2
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js
  29. 2 2
      dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js
  30. 2 2
      dist/min/inputmask/global/document.min.js
  31. 2 2
      dist/min/inputmask/global/window.min.js
  32. 3 3
      dist/min/inputmask/inputmask.date.extensions.min.js
  33. 2 2
      dist/min/inputmask/inputmask.extensions.min.js
  34. 2 2
      dist/min/inputmask/inputmask.min.js
  35. 2 2
      dist/min/inputmask/inputmask.numeric.extensions.min.js
  36. 2 2
      dist/min/inputmask/inputmask.phone.extensions.min.js
  37. 2 2
      dist/min/inputmask/jquery.inputmask.min.js
  38. 2 2
      dist/min/inputmask/phone-codes/phone-be.min.js
  39. 2 2
      dist/min/inputmask/phone-codes/phone-ca.min.js
  40. 2 2
      dist/min/inputmask/phone-codes/phone-mx.min.js
  41. 2 2
      dist/min/inputmask/phone-codes/phone-nl.min.js
  42. 2 2
      dist/min/inputmask/phone-codes/phone-ru.min.js
  43. 2 2
      dist/min/inputmask/phone-codes/phone-uk.min.js
  44. 2 2
      dist/min/inputmask/phone-codes/phone-us.min.js
  45. 2 2
      dist/min/inputmask/phone-codes/phone.min.js
  46. 3 3
      dist/min/jquery.inputmask.bundle.min.js
  47. 4 4
      js/inputmask.date.extensions.js
  48. 1 1
      package.json
  49. 9 2
      qunit/tests_date.js

+ 1 - 1
README.md

@@ -1,6 +1,6 @@
 # Inputmask
 
-Copyright (c) 2010 - 2017 Robin Herbots Licensed under the MIT license ([http://opensource.org/licenses/mit-license.php](http://opensource.org/licenses/mit-license.php))
+Copyright (c) 2010 - 2018 Robin Herbots Licensed under the MIT license ([http://opensource.org/licenses/mit-license.php](http://opensource.org/licenses/mit-license.php))
 
 [![NPM Version][npm-image]][npm-url] [![Dependency Status][david-image]][david-url] [![devDependency Status][david-dev-image]][david-dev-url]
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-78",
+  "version": "4.0.0-79",
   "main": [
 	  "./dist/inputmask/inputmask.js",
 	  "./dist/inputmask/inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
 	"name": "inputmask",
 	"repository": "robinherbots/Inputmask",
 	"description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-	"version": "4.0.0-78",
+	"version": "4.0.0-79",
 	"keywords": [
 		"jquery",
 		"plugins",

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "4.0.0-78",
+  "version": "4.0.0-79",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 2 - 2
dist/inputmask/bindings/inputmask.binding.js

@@ -1,9 +1,9 @@
 /*!
 * bindings/inputmask.binding.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.js

@@ -1,9 +1,9 @@
 /*!
 * dependencyLibs/inputmask.dependencyLib.jqlite.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.js

@@ -1,9 +1,9 @@
 /*!
 * dependencyLibs/inputmask.dependencyLib.jquery.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/dependencyLibs/inputmask.dependencyLib.js

@@ -1,9 +1,9 @@
 /*!
 * dependencyLibs/inputmask.dependencyLib.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/global/document.js

@@ -1,9 +1,9 @@
 /*!
 * global/document.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 2 - 2
dist/inputmask/global/window.js

@@ -1,9 +1,9 @@
 /*!
 * global/window.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 "function" == typeof define && define.amd ? define(function() {

+ 3 - 3
dist/inputmask/inputmask.date.extensions.js

@@ -1,9 +1,9 @@
 /*!
 * inputmask.date.extensions.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {
@@ -140,7 +140,7 @@
             onKeyDown: function(e, buffer, caretPos, opts) {
                 var input = this;
                 if (e.ctrlKey && e.keyCode === Inputmask.keyCode.RIGHT) {
-                    for (var match, today = new Date(), date = ""; match = getTokenizer(opts).exec(opts.inputFormat); ) "d" === match[0].charAt(0) ? date += today.getDate().toString() : "m" === match[0].charAt(0) ? date += (today.getMonth() + 1).toString() : "yyyy" === match[0] ? date += today.getFullYear().toString() : "yy" === match[0] && (date += today.getYear().toString());
+                    for (var match, today = new Date(), date = ""; match = getTokenizer(opts).exec(opts.inputFormat); ) "d" === match[0].charAt(0) ? date += pad(today.getDate(), match[0].length) : "m" === match[0].charAt(0) ? date += pad(today.getMonth() + 1, match[0].length) : "yyyy" === match[0] ? date += today.getFullYear().toString() : "y" === match[0].charAt(0) && (date += pad(today.getYear(), match[0].length));
                     input.inputmask._valueSet(date), $(input).trigger("setvalue");
                 }
             },

+ 2 - 2
dist/inputmask/inputmask.extensions.js

@@ -1,9 +1,9 @@
 /*!
 * inputmask.extensions.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/inputmask.js

@@ -1,9 +1,9 @@
 /*!
 * inputmask.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/inputmask.numeric.extensions.js

@@ -1,9 +1,9 @@
 /*!
 * inputmask.numeric.extensions.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/inputmask.phone.extensions.js

@@ -1,9 +1,9 @@
 /*!
 * inputmask.phone.extensions.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/jquery.inputmask.js

@@ -1,9 +1,9 @@
 /*!
 * jquery.inputmask.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-be.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-be.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-ca.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-ca.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-mx.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-mx.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-nl.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-nl.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-ru.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-ru.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-uk.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-uk.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone-us.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone-us.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

+ 2 - 2
dist/inputmask/phone-codes/phone.js

@@ -1,9 +1,9 @@
 /*!
 * phone-codes/phone.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(factory) {

文件差异内容过多而无法显示
+ 4 - 4
dist/jquery.inputmask.bundle.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/bindings/inputmask.binding.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jqlite.min.js


+ 2 - 2
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.jquery.min.js

@@ -1,9 +1,9 @@
 /*!
 * dependencyLibs/inputmask.dependencyLib.jquery.min.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):window.dependencyLib=e(jQuery)}(function(e){return e});

文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/dependencyLibs/inputmask.dependencyLib.min.js


+ 2 - 2
dist/min/inputmask/global/document.min.js

@@ -1,9 +1,9 @@
 /*!
 * global/document.min.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 "function"==typeof define&&define.amd?define(function(){return document}):"object"==typeof exports&&(module.exports=document);

+ 2 - 2
dist/min/inputmask/global/window.min.js

@@ -1,9 +1,9 @@
 /*!
 * global/window.min.js
 * https://github.com/RobinHerbots/Inputmask
-* Copyright (c) 2010 - 2017 Robin Herbots
+* Copyright (c) 2010 - 2018 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 4.0.0-78
+* Version: 4.0.0-79
 */
 
 "function"==typeof define&&define.amd?define(function(){return window}):"object"==typeof exports&&(module.exports=window);

文件差异内容过多而无法显示
+ 3 - 3
dist/min/inputmask/inputmask.date.extensions.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.extensions.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.numeric.extensions.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/inputmask.phone.extensions.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/jquery.inputmask.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-be.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-ca.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-mx.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-nl.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-ru.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-uk.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone-us.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/min/inputmask/phone-codes/phone.min.js


文件差异内容过多而无法显示
+ 3 - 3
dist/min/jquery.inputmask.bundle.min.js


+ 4 - 4
js/inputmask.date.extensions.js

@@ -223,13 +223,13 @@
 
                     while (match = getTokenizer(opts).exec(opts.inputFormat)) {
                         if (match[0].charAt(0) === "d") {
-                            date += today.getDate().toString();
+                            date += pad(today.getDate(), match[0].length);
                         } else if (match[0].charAt(0) === "m") {
-                            date += (today.getMonth() + 1).toString();
+                            date += pad((today.getMonth() + 1), match[0].length);
                         } else if (match[0] === "yyyy") {
                             date += today.getFullYear().toString();
-                        } else if (match[0] === "yy") {
-                            date += today.getYear().toString();
+                        } else if (match[0].charAt(0) === "y") {
+                            date += pad(today.getYear(), match[0].length);
                         }
                     }
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "4.0.0-78",
+  "version": "4.0.0-79",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "index.js",
   "files": [

+ 9 - 2
qunit/tests_date.js

@@ -1,4 +1,11 @@
 export default function (qunit, $, Inputmask) {
+    function pad(val, len) {
+        val = String(val);
+        len = len || 2;
+        while (val.length < len) val = "0" + val;
+        return val;
+    }
+
     qunit.module("Date.Extensions - dd/mm/yyyy");
     qunit.test("valid entry", function (assert) {
         var $fixture = $("#qunit-fixture");
@@ -67,7 +74,7 @@ export default function (qunit, $, Inputmask) {
         testmask.focus();
         $("#testmask").SendKey(Inputmask.keyCode.RIGHT, Inputmask.keyCode.CONTROL);
         var today = new Date();
-        today = "00".substr(0, 2 - today.getDate().toString().length) + today.getDate() + "/" + (parseInt(today.getMonth()) + 1) + "/" + today.getFullYear();
+        today = pad(today.getDate(), 2) + "/" + pad(parseInt(today.getMonth()) + 1, 2) + "/" + today.getFullYear();
         assert.equal(testmask.value, today, "Result " + testmask.value);
     });
     qunit.test("backspace year", function (assert) {
@@ -242,7 +249,7 @@ export default function (qunit, $, Inputmask) {
         testmask.focus();
         $("#testmask").SendKey(Inputmask.keyCode.RIGHT, Inputmask.keyCode.CONTROL);
         var today = new Date();
-        today = (parseInt(today.getMonth()) + 1) + "/" + "00".substr(0, 2 - today.getDate().toString().length) + today.getDate() + "/" + today.getFullYear();
+        today = pad(parseInt(today.getMonth()) + 1, 2) + "/" + pad(today.getDate(), 2) + "/" + today.getFullYear();
         assert.equal(testmask.value, today, "Result " + testmask.value);
     });
     qunit.test("backspace year", function (assert) {