aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/mixin/CommonMixin.js
diff options
context:
space:
mode:
author崖鹰 <zhao.wuz@alipay.com>2015-11-13 11:33:48 +0800
committer崖鹰 <zhao.wuz@alipay.com>2015-11-13 11:33:48 +0800
commit02de449a0474765a4796fa607e7e3922252f574f (patch)
treedc37faf2f610343112ea1fc3707ad188092bd031 /src/mixin/CommonMixin.js
parent1f336fabc9135ac971e53d9c2ae407db69b8f096 (diff)
downloadtime-picker-02de449a0474765a4796fa607e7e3922252f574f.tar.gz
time-picker-02de449a0474765a4796fa607e7e3922252f574f.tar.zst
time-picker-02de449a0474765a4796fa607e7e3922252f574f.zip
release 0.1.0
Diffstat (limited to 'src/mixin/CommonMixin.js')
-rw-r--r--src/mixin/CommonMixin.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mixin/CommonMixin.js b/src/mixin/CommonMixin.js
new file mode 100644
index 0000000..4203a9e
--- /dev/null
+++ b/src/mixin/CommonMixin.js
@@ -0,0 +1,46 @@
1import {PropTypes} from 'react';
2import enUs from '../locale/en_US';
3import {getFormatter} from '../util/index';
4
5export default {
6 propTypes: {
7 prefixCls: PropTypes.string,
8 locale: PropTypes.object,
9 },
10
11 getDefaultProps() {
12 return {
13 prefixCls: 'rc-timepicker',
14 locale: enUs,
15 };
16 },
17
18 getFormatter() {
19 const formatter = this.props.formatter;
20 const locale = this.props.locale;
21 if (formatter) {
22 if (formatter === this.lastFormatter) {
23 return this.normalFormatter;
24 }
25 this.normalFormatter = getFormatter(formatter, locale);
26 this.lastFormatter = formatter;
27 return this.normalFormatter;
28 }
29 if (!this.showSecond) {
30 if (!this.notShowSecondFormatter) {
31 this.notShowSecondFormatter = getFormatter('HH:mm', locale);
32 }
33 return this.notShowSecondFormatter;
34 }
35 if (!this.showHour) {
36 if (!this.notShowHourFormatter) {
37 this.notShowHourFormatter = getFormatter('mm:ss', locale);
38 }
39 return this.notShowHourFormatter;
40 }
41 if (!this.normalFormatter) {
42 this.normalFormatter = getFormatter('HH:mm:ss', locale);
43 }
44 return this.normalFormatter;
45 },
46};