he wei
2024-10-08 96ee251c889b4a7cd65134658ac5c2d4d5fa1798
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * 将秒转化成时:分
 *
 * @param   {[Number]}  value  分
 *
 * @return  {[String]}         00h00m
 */
function formatMinutes(value = 0) {
  if (value <= 0) {
    value = 0;
  }
  // 分
  var theTime = parseInt(value);
  // 小时
  var theTime1 = 0;
  if (theTime >= 60) {
    theTime1 = parseInt(theTime / 60);
    theTime = parseInt(theTime % 60);
    //alert(theTime1+"-"+theTime);
  }
  var result = (theTime < 10 ? "0" : "") + parseInt(theTime);
  if (theTime1 >= 0) {
    result = (theTime1 < 10 ? "0" : "") + parseInt(theTime1) + "h" + result + 'm';
  }
  return result;
}
 
export default formatMinutes;