ZZJ
2022-06-01 f3bf27d9bc7c8c6484be4f37edcc57df5490ecbe
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(number) {
    // return (number > 1) ? 's' : ''
    return ''
  }
}
 
export function kebabCase(s) {
  return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)
}