ZZJ
2022-03-09 cc7401e771e13b40bb7dea11ec26da3acfc8e5c7
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
export function secondsToStr(temp) {
  const years = Math.floor(temp / 31536000);
  if (years) {
    return years + " 年" + numberEnding(years);
  }
  const days = Math.floor((temp %= 31536000) / 86400);
  if (days) {
    return days + " 天" + numberEnding(days);
  }
  const hours = Math.floor((temp %= 86400) / 3600);
  if (hours) {
    return hours + " 小时" + numberEnding(hours);
  }
  const minutes = Math.floor((temp %= 3600) / 60);
  if (minutes) {
    return minutes + " 分" + numberEnding(minutes);
  }
  const seconds = temp % 60;
  return seconds + " 秒" + numberEnding(seconds);
  function numberEnding() {
    // return (number > 1) ? 's' : ''
    return "";
  }
}
 
export function kebabCase(s) {
  return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
}