4949 {{ __pad(minute) }}
5050 </span >
5151 </div >
52- <div class =" q-datetime-ampm column justify-around" >
52+ <div v-if = " !format24h " class =" q-datetime-ampm column justify-around" >
5353 <div
5454 :class =" {active: am}"
5555 class =" q-datetime-link"
156156 <div class =" q-datetime-clock-pointer" :style =" clockPointerStyle" :class =" {hidden: !value}" >
157157 <span ></span >
158158 </div >
159- <div
160- v-for =" n in 12"
161- class =" q-datetime-clock-position"
162- :class =" ['q-datetime-clock-pos-' + n, value && n === hour ? 'active' : '']"
163- >
164- {{ n }}
159+ <div v-if =" format24h" >
160+ <div
161+ v-for =" n in 24"
162+ class =" q-datetime-clock-position fmt24"
163+ :class =" [`q-datetime-clock-pos-${n-1}`, value && (n - 1) === hour ? 'active' : '']"
164+ >
165+ {{ n - 1 }}
166+ </div >
167+ </div >
168+ <div v-else >
169+ <div
170+ v-for =" n in 12"
171+ class =" q-datetime-clock-position"
172+ :class =" ['q-datetime-clock-pos-' + n, value && n === hour ? 'active' : '']"
173+ >
174+ {{ n }}
175+ </div >
165176 </div >
166177 </div >
167178 </div >
201212<script >
202213import { moment } from ' ../../deps'
203214import { inline as props } from ' ./datetime-props'
204- import { height , width , offset } from ' ../../utils/dom'
215+ import { height , width , offset , cssTransform } from ' ../../utils/dom'
205216import { between } from ' ../../utils/format'
206217import { position } from ' ../../utils/event'
207218import { QIcon } from ' ../icon'
@@ -374,7 +385,10 @@ export default {
374385 },
375386
376387 hour () {
377- return convertToAmPm (this .date .hour ())
388+ const h = this .date .hour ()
389+ return this .format24h
390+ ? h
391+ : convertToAmPm (h)
378392 },
379393 minute () {
380394 return this .date .minute ()
@@ -384,14 +398,10 @@ export default {
384398 },
385399 clockPointerStyle () {
386400 let
387- divider = this .view === ' minute' ? 60 : 12 ,
401+ divider = this .view === ' minute' ? 60 : ( this . format24h ? 24 : 12 ) ,
388402 degrees = Math .round ((this .view === ' minute' ? this .minute : this .hour ) * (360 / divider)) - 180
389403
390- return {
391- ' -webkit-transform' : ' rotate(' + degrees + ' deg)' ,
392- ' -ms-transform' : ' rotate(' + degrees + ' deg)' ,
393- ' transform' : ' rotate(' + degrees + ' deg)'
394- }
404+ return cssTransform (` rotate(${ degrees} deg)` )
395405 },
396406 editable () {
397407 return ! this .disable && ! this .readonly
@@ -439,11 +449,16 @@ export default {
439449 if (! this .editable ) {
440450 return
441451 }
442- this .view = ' minute'
443- value = this .__parseTypeValue (' hour' , value) % 12
452+ value = this .__parseTypeValue (' hour' , value)
444453
445- if (! this .am ) {
446- value += 12
454+ if (this .format24h ) {
455+ value = value % 24
456+ }
457+ else {
458+ value = value % 12
459+ if (! this .am ) {
460+ value += 12
461+ }
447462 }
448463
449464 this .date .hour (value)
@@ -489,6 +504,7 @@ export default {
489504 ev .stopPropagation ()
490505 ev .preventDefault ()
491506 this .dragging = false
507+ this .view = ' minute'
492508 },
493509 __updateClock (ev ) {
494510 let
@@ -508,7 +524,7 @@ export default {
508524 }
509525
510526 if (this .view === ' hour' ) {
511- this .setHour (Math .round (angle / 30 ))
527+ this .setHour (Math .round (angle / ( this . format24h ? 15 : 30 ) ))
512528 }
513529 else {
514530 this .setMinute (Math .round (angle / 6 ))
0 commit comments