]> git.immae.eu Git - github/fretlink/time-picker.git/commitdiff
Added support for lower/uppercase of AM/PM selectors
authorAntony Shaleynikov <shaleynikov@gmail.com>
Mon, 6 Mar 2017 09:51:39 +0000 (12:51 +0300)
committerAntony Shaleynikov <shaleynikov@gmail.com>
Mon, 6 Mar 2017 09:51:39 +0000 (12:51 +0300)
examples/12hours.js
src/Combobox.jsx

index 44e514af68bce7d0b3a5831b044c63e16b98b0d0..16e428d4150b4e8a4f33ac3730265f32a7ca36be 100644 (file)
@@ -10,7 +10,7 @@ import moment from 'moment';
 import TimePicker from 'rc-time-picker';
 
 const showSecond = false;
-const str = showSecond ? 'HH:mm:ss' : 'HH:mm';
+const str = showSecond ? 'h:mm a' : 'h:mm a';
 
 const now = moment().hour(0).minute(0);
 
@@ -24,6 +24,7 @@ ReactDom.render(
     defaultValue={now}
     className="xxx"
     onChange={onChange}
+    format={str}
     use12Hours
   />,
   document.getElementById('__react-content')
index 958e108baef5e3bcd08a61e9349abc4014411299..00f122f357131ac4ada00df20594c5b62493a5a8 100644 (file)
@@ -145,11 +145,15 @@ const Combobox = React.createClass({
   },
 
   getAMPMSelect() {
-    const { prefixCls, use12Hours } = this.props;
+    const { prefixCls, use12Hours, format } = this.props;
     if (!use12Hours) {
       return null;
     }
-    const AMPMOptions = [{ value: 'AM' }, { value: 'PM' }];
+
+    const AMPMOptions = ['am', 'pm'] // If format has A char, then we should uppercase AM/PM
+                          .map(c => format.match(/\sA/) ? c.toUpperCase() : c)
+                          .map(c => ({ value: c }));
+
     const selected = this.isAM() ? 0 : 1;
 
     return (