File tree Expand file tree Collapse file tree 1 file changed +27
-9
lines changed Expand file tree Collapse file tree 1 file changed +27
-9
lines changed Original file line number Diff line number Diff line change 1130
1130
return false ;
1131
1131
} ;
1132
1132
1133
+ _convert24to12 = function ( hour ) {
1134
+ if ( hour > 12 ) {
1135
+ hour = hour - 12 ;
1136
+ }
1137
+
1138
+ if ( hour == 0 ) {
1139
+ hour = 12 ;
1140
+ }
1141
+
1142
+ var result ;
1143
+ if ( hour < 10 ) {
1144
+ result = "0" + hour ;
1145
+ }
1146
+ else {
1147
+ result = String ( hour ) ;
1148
+ }
1149
+
1150
+ return result ;
1151
+ } ;
1152
+
1133
1153
/*
1134
1154
* Public utility to format the time
1135
1155
* format = string format of the time
1154
1174
if ( options . ampm ) {
1155
1175
if ( hour > 11 ) {
1156
1176
ampmName = options . pmNames [ 0 ] ;
1157
- if ( hour > 12 ) {
1158
- hour = hour % 12 ;
1159
- }
1160
- }
1161
- if ( hour === 0 ) {
1162
- hour = 12 ;
1163
1177
}
1164
1178
}
1165
- tmptime = tmptime . replace ( / (?: h h ? | m m ? | s s ? | [ t T ] { 1 , 2 } | [ l z ] | ' .* ?' ) / g, function ( match ) {
1166
- switch ( match . toLowerCase ( ) ) {
1179
+ tmptime = tmptime . replace ( / (?: H H ? | h h ? | m m ? | s s ? | [ t T ] { 1 , 2 } | [ l z ] | ( ' .* ?' | " .* ?" ) ) / g, function ( match ) {
1180
+ switch ( match ) {
1181
+ case 'HH' :
1182
+ return _convert24to12 ( hour ) . slice ( - 2 ) ;
1183
+ case 'H' :
1184
+ return _convert24to12 ( hour ) ;
1167
1185
case 'hh' :
1168
1186
return ( '0' + hour ) . slice ( - 2 ) ;
1169
1187
case 'h' :
1847
1865
*/
1848
1866
$ . timepicker . version = "1.1.0" ;
1849
1867
1850
- } ) ( jQuery ) ;
1868
+ } ) ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments