@@ -23,20 +23,33 @@ var DateTimePickerTime = React.createClass({
23
23
}
24
24
}
25
25
26
+ let daypart = false ;
27
+ if ( this . props . timeFormat . indexOf ( ' A' ) != - 1 && this . state != null ) {
28
+ daypart = ( this . state . hours > 12 ) ? 'PM' : 'AM' ;
29
+ }
30
+
26
31
return {
27
32
hours : date . format ( 'H' ) ,
28
33
minutes : date . format ( 'mm' ) ,
29
34
seconds : date . format ( 'ss' ) ,
30
35
milliseconds : date . format ( 'SSS' ) ,
36
+ daypart : daypart ,
31
37
counters : counters
32
38
} ;
33
39
} ,
34
40
renderCounter : function ( type ) {
35
- return DOM . div ( { key : type , className : 'rdtCounter' } , [
36
- DOM . span ( { key :'up' , className : 'rdtBtn' , onMouseDown : this . onStartClicking ( 'increase' , type ) } , '▲' ) ,
37
- DOM . div ( { key :'c' , className : 'rdtCount' } , this . state [ type ] ) ,
38
- DOM . span ( { key :'do' , className : 'rdtBtn' , onMouseDown : this . onStartClicking ( 'decrease' , type ) } , '▼' )
39
- ] ) ;
41
+ if ( type !== 'daypart' ) {
42
+ let value = this . state [ type ] ;
43
+ if ( type === 'hours' && this . props . timeFormat . indexOf ( ' A' ) != - 1 && value > 12 ) {
44
+ value = value - 12 ;
45
+ }
46
+ return DOM . div ( { key : type , className : 'rdtCounter' } , [
47
+ DOM . span ( { key :'up' , className : 'rdtBtn' , onMouseDown : this . onStartClicking ( 'increase' , type ) } , '▲' ) ,
48
+ DOM . div ( { key :'c' , className : 'rdtCount' } , value ) ,
49
+ DOM . span ( { key :'do' , className : 'rdtBtn' , onMouseDown : this . onStartClicking ( 'decrease' , type ) } , '▼' )
50
+ ] ) ;
51
+ }
52
+ return '' ;
40
53
} ,
41
54
render : function ( ) {
42
55
var me = this ,
@@ -49,6 +62,11 @@ var DateTimePickerTime = React.createClass({
49
62
counters . push ( me . renderCounter ( c ) ) ;
50
63
} ) ;
51
64
65
+
66
+ if ( this . state . daypart !== false ) {
67
+ counters . push ( DOM . div ( { key : this . state . daypart , className : 'rdtDayPart' } , this . state . daypart ) ) ;
68
+ }
69
+
52
70
if ( this . state . counters . length == 3 && this . props . timeFormat . indexOf ( 'S' ) != - 1 ) {
53
71
counters . push ( DOM . div ( { className : 'rdtCounterSeparator' , key : 'sep5' } , ':' ) ) ;
54
72
counters . push (
0 commit comments