MCPcopy
hub / github.com/jonthornton/jquery-timepicker / _int2time

Method _int2time

src/timepicker/index.js:464–551  ·  view source on GitHub ↗
(timeInt)

Source from the content-addressed store, hash-verified

462 }
463
464 _int2time(timeInt) {
465 if (typeof timeInt != "number") {
466 return null;
467 }
468
469 var seconds = parseInt(timeInt % 60),
470 minutes = parseInt((timeInt / 60) % 60),
471 hours = parseInt((timeInt / (60 * 60)) % 24);
472
473 var time = new Date(1970, 0, 2, hours, minutes, seconds, 0);
474
475 if (isNaN(time.getTime())) {
476 return null;
477 }
478
479 if (typeof this.settings.timeFormat === "function") {
480 return this.settings.timeFormat(time);
481 }
482
483 var output = "";
484 var hour, code;
485 for (var i = 0; i < this.settings.timeFormat.length; i++) {
486 code = this.settings.timeFormat.charAt(i);
487 switch (code) {
488 case "a":
489 output +=
490 time.getHours() > 11
491 ? this.settings.lang.pm
492 : this.settings.lang.am;
493 break;
494
495 case "A":
496 output +=
497 time.getHours() > 11
498 ? this.settings.lang.PM
499 : this.settings.lang.AM;
500 break;
501
502 case "g":
503 hour = time.getHours() % 12;
504 output += hour === 0 ? "12" : hour;
505 break;
506
507 case "G":
508 hour = time.getHours();
509 if (timeInt === ONE_DAY) hour = this.settings.show2400 ? 24 : 0;
510 output += hour;
511 break;
512
513 case "h":
514 hour = time.getHours() % 12;
515
516 if (hour !== 0 && hour < 10) {
517 hour = "0" + hour;
518 }
519
520 output += hour === 0 ? "12" : hour;
521 break;

Callers 10

_roundAndFormatTimeMethod · 0.95
_formatValueMethod · 0.95
yFunction · 0.80
_getDropdownTimesFunction · 0.80
_selectValueMethod · 0.80
_getDropdownTimesFunction · 0.80
timepicker-test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected