m-datetime-picker
Advanced tools
Comparing version 1.0.2 to 1.0.3
46
index.js
@@ -161,23 +161,24 @@ 'use strict'; | ||
var _result = []; | ||
var dfv = this.props.defaultValue; | ||
// 可以没有默认值 | ||
if (!this.props.defaultValue) return ''; | ||
var initDate = new Date(this.props.defaultValue); | ||
if (+initDate > +this.maxDate) initDate = this.maxDate; | ||
if (+initDate < +this.minDate) initDate = this.minDate; | ||
this.fmtAry.forEach(function (x) { | ||
if (x === 'Y') { | ||
_result.push(initDate.getFullYear()); | ||
} else if (x === 'M') { | ||
_result.push(formatNumber(initDate.getMonth() + 1)); | ||
} else if (x === 'd') { | ||
_result.push(formatNumber(initDate.getDate())); | ||
} else if (x === 'H') { | ||
_result.push(formatNumber(initDate.getHours())); | ||
} else if (x === 'm') { | ||
_result.push(formatNumber(initDate.getMinutes())); | ||
} else if (x === 's') { | ||
_result.push(formatNumber(initDate.getSeconds())); | ||
} | ||
}); | ||
if (dfv) { | ||
var initDate = new Date(dfv); | ||
if (+initDate > +this.maxDate) initDate = this.maxDate; | ||
if (+initDate < +this.minDate) initDate = this.minDate; | ||
this.fmtAry.forEach(function (x) { | ||
if (x === 'Y') { | ||
_result.push(initDate.getFullYear()); | ||
} else if (x === 'M') { | ||
_result.push(formatNumber(initDate.getMonth() + 1)); | ||
} else if (x === 'd') { | ||
_result.push(formatNumber(initDate.getDate())); | ||
} else if (x === 'H') { | ||
_result.push(formatNumber(initDate.getHours())); | ||
} else if (x === 'm') { | ||
_result.push(formatNumber(initDate.getMinutes())); | ||
} else if (x === 's') { | ||
_result.push(formatNumber(initDate.getSeconds())); | ||
} | ||
}); | ||
} | ||
return _result; | ||
@@ -188,2 +189,5 @@ } | ||
value: function getFmtValue(picker, values, displayValues) { | ||
// 如果是空数组,表示此时日期选择器默认值是空,不需要补全“年月日”的汉字 | ||
if (!displayValues.length) return '' | ||
var _result = []; | ||
@@ -232,3 +236,3 @@ var index = 0; | ||
onChange: _react.PropTypes.func, | ||
defaultValue: _react.PropTypes.number, // 默认的时间,timestamp,默认为现在 | ||
defaultValue: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]),// 默认的时间,timestamp,默认为现在 | ||
dateFormat: _react.PropTypes.string, // Y: 年, M: 月, d: 日期, H: 时, m: 分, s: 秒,如果格式不规范,可能会导致一些奇怪的结果 | ||
@@ -235,0 +239,0 @@ minDate: _react.PropTypes.string, // 起始日期, xxxx-xx-xx格式 |
{ | ||
"name": "m-datetime-picker", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "m-datetime-picker 日期时间选择器,基于m-picker扩展来", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# m-datetime-pciker | ||
# m-datetime-picker | ||
@@ -7,2 +7,8 @@ --- | ||
## 安装 | ||
``` | ||
npm i m-datetime-picker --save | ||
``` | ||
## 何时使用 | ||
@@ -9,0 +15,0 @@ |
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
24289
227
48