diff options
author | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-16 22:08:04 -0800 |
commit | 0175cb67e426a27a3ecfb7b81317caa383c8a5a5 (patch) | |
tree | b4fbfcaabaadff508ad5463e8f71fd643995aacb /node_modules/montage/core/converter | |
parent | fe71cb9aa1700199c0089166ad54fc56eb760644 (diff) | |
parent | 9f0c4efe2ed9a00f2c5d85c9d88a8040fedb5d8f (diff) | |
download | ninja-0175cb67e426a27a3ecfb7b81317caa383c8a5a5.tar.gz |
Merge branch 'refs/heads/master' into components
Diffstat (limited to 'node_modules/montage/core/converter')
-rwxr-xr-x | node_modules/montage/core/converter/converter.js | 10 | ||||
-rwxr-xr-x | node_modules/montage/core/converter/date-converter.js | 10 |
2 files changed, 5 insertions, 15 deletions
diff --git a/node_modules/montage/core/converter/converter.js b/node_modules/montage/core/converter/converter.js index abce44e2..a23d2702 100755 --- a/node_modules/montage/core/converter/converter.js +++ b/node_modules/montage/core/converter/converter.js | |||
@@ -20,16 +20,6 @@ var FUNCTION_CLASS = '[object Function]', | |||
20 | 20 | ||
21 | var _toString = Object.prototype.toString; | 21 | var _toString = Object.prototype.toString; |
22 | 22 | ||
23 | // TODO should maybe move these into String.isString and Number.isNumber to parallel Array.isArray | ||
24 | |||
25 | /** | ||
26 | @exports module:montage/core/converter#isString | ||
27 | @function | ||
28 | */ | ||
29 | var isString = function(object) { | ||
30 | return _toString.call(object) === STRING_CLASS; | ||
31 | }; | ||
32 | exports.isString = isString; | ||
33 | 23 | ||
34 | /** | 24 | /** |
35 | @exports module:montage/core/converter#isNumber | 25 | @exports module:montage/core/converter#isNumber |
diff --git a/node_modules/montage/core/converter/date-converter.js b/node_modules/montage/core/converter/date-converter.js index f0d3e540..f484f7aa 100755 --- a/node_modules/montage/core/converter/date-converter.js +++ b/node_modules/montage/core/converter/date-converter.js | |||
@@ -2502,16 +2502,13 @@ var _toString = Object.prototype.toString; | |||
2502 | var isDate = function(object) { | 2502 | var isDate = function(object) { |
2503 | return _toString.call(object) === DATE_CLASS; | 2503 | return _toString.call(object) === DATE_CLASS; |
2504 | }; | 2504 | }; |
2505 | var isString = function(object) { | ||
2506 | return _toString.call(object) === STRING_CLASS; | ||
2507 | }; | ||
2508 | var isNumber = function(object) { | 2505 | var isNumber = function(object) { |
2509 | return _toString.call(object) === NUMBER_CLASS; | 2506 | return _toString.call(object) === NUMBER_CLASS; |
2510 | }; | 2507 | }; |
2511 | 2508 | ||
2512 | var formatDate = function(v, format) { | 2509 | var formatDate = function(v, format) { |
2513 | var date; | 2510 | var date; |
2514 | if (isString(v)) { | 2511 | if (String.isString(v)) { |
2515 | // try to create a Date instance from the string | 2512 | // try to create a Date instance from the string |
2516 | // date must be a string that can be parsed by Date | 2513 | // date must be a string that can be parsed by Date |
2517 | // see - http://www.w3schools.com/jsref/jsref_parse.asp | 2514 | // see - http://www.w3schools.com/jsref/jsref_parse.asp |
@@ -2605,7 +2602,7 @@ var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends | |||
2605 | */ | 2602 | */ |
2606 | convert: { | 2603 | convert: { |
2607 | value: function(v) { | 2604 | value: function(v) { |
2608 | if (isDate(v) || isString(v) || isNumber(v)) { | 2605 | if (isDate(v) || String.isString(v) || isNumber(v)) { |
2609 | return formatDate(v, this.pattern); | 2606 | return formatDate(v, this.pattern); |
2610 | } | 2607 | } |
2611 | return v; | 2608 | return v; |
@@ -2617,6 +2614,9 @@ var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends | |||
2617 | */ | 2614 | */ |
2618 | revert: { | 2615 | revert: { |
2619 | value: function(v) { | 2616 | value: function(v) { |
2617 | if(isDate(v)) { | ||
2618 | return v; | ||
2619 | } | ||
2620 | this.validator.pattern = this.pattern; | 2620 | this.validator.pattern = this.pattern; |
2621 | 2621 | ||
2622 | var result = this.validator.validate(v); | 2622 | var result = this.validator.validate(v); |