1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export function getTimeString(timeIndex: number, index: number) { 17 let result = timeIndex + index - 3 18 if (result < 0) { 19 return ' ' 20 } 21 if (result % 60 < 10) { 22 return '0' + Math.floor(result / 60) + ':0' + (result % 60) 23 } 24 if (result % 60 >= 10) { 25 return '0' + Math.floor(result / 60) + ':' + (result % 60) 26 } 27} 28 29export function updateTime(millisecond: number) { 30 let minute = parseInt((millisecond / 60000).toString()) 31 let second = parseInt(((millisecond - (minute * 60000)) / 1000).toString()) 32 let minuteStr = '' + minute 33 let secondStr = '' + second 34 if (minute < 10) { 35 minuteStr = "0" + minute 36 } 37 if (second < 10) { 38 secondStr = "0" + second 39 } 40 return minuteStr + ':' + secondStr; 41}