MCPcopy Create free account
hub / github.com/circircir-circle/human_exist_device / parseFormat

Method parseFormat

mini_program/common/Tools.js:796–828  ·  view source on GitHub ↗
(format, timeData)

Source from the content-addressed store, hash-verified

794 }
795
796 parseFormat(format, timeData) {
797 let {
798 days,
799 hours,
800 minutes,
801 seconds,
802 milliseconds
803 } = timeData
804 // 如果格式化字符串中不存在DD(天),则将天的时间转为小时中去
805 if (format.indexOf('DD') === -1) {
806 hours += days * 24
807 } else {
808 // 对天补0
809 format = format.replace('DD', this.padZero(days))
810 }
811 // 其他同理于DD的格式化处理方式
812 if (format.indexOf('HH') === -1) {
813 minutes += hours * 60
814 } else {
815 format = format.replace('HH', this.padZero(hours))
816 }
817 if (format.indexOf('mm') === -1) {
818 seconds += minutes * 60
819 } else {
820 format = format.replace('mm', this.padZero(minutes))
821 }
822 if (format.indexOf('ss') === -1) {
823 milliseconds += seconds * 1000
824 } else {
825 format = format.replace('ss', this.padZero(seconds))
826 }
827 return format.replace('SSS', this.padZero(milliseconds, 3))
828 }
829
830 isSameSecond(time1, time2) {
831 return Math.floor(time1 / 1000) === Math.floor(time2 / 1000)

Callers

nothing calls this directly

Calls 1

padZeroMethod · 0.95

Tested by

no test coverage detected