@operato/scene-timer 1.2.87 → 1.2.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,8 +4,8 @@
4
4
  * @param {String} i
5
5
  * @param {Number} len
6
6
  */
7
- function ii(i: number, len?: number) {
8
- var s = i + ''
7
+ function ii(i: string, len?: number) {
8
+ var s = i
9
9
  len = len || 2
10
10
  while (s.length < len) s = '0' + s
11
11
  return s
@@ -15,33 +15,33 @@ function ii(i: number, len?: number) {
15
15
  * 시간 표시 포맷을 맞추는 함수
16
16
  *
17
17
  * @param {Number} seconds seconds
18
- * @param {string} format hh:mm:ss
18
+ * @param {string} timeFormat hh:mm:ss
19
19
  */
20
- export default function format(seconds = 0, format = '') {
20
+ export default function formatTime(seconds = 0, timeFormat = '') {
21
21
  var h = 0,
22
22
  m = 0,
23
23
  s = 0
24
- var formated = ''
24
+ var formatted = ''
25
25
 
26
26
  h = Math.floor(seconds / 3600)
27
- formated = format.replace(/(^|[^\\])hh+/g, '$1' + ii(h))
28
- formated = formated.replace(/(^|[^\\])h/g, '$1' + h)
29
- if (format != formated) {
30
- format = formated
31
- seconds %= 1440
27
+ formatted = timeFormat.replace(/(^|[^\\])hh+/g, '$1' + ii(h.toString()))
28
+ formatted = formatted.replace(/(^|[^\\])h/g, '$1' + h)
29
+ if (timeFormat !== formatted) {
30
+ timeFormat = formatted
31
+ seconds %= 3600
32
32
  }
33
33
 
34
34
  m = Math.floor(seconds / 60)
35
- formated = format.replace(/(^|[^\\])mm+/g, '$1' + ii(m))
36
- formated = formated.replace(/(^|[^\\])m/g, '$1' + m)
37
- if (format != formated) {
38
- format = formated
35
+ formatted = timeFormat.replace(/(^|[^\\])mm+/g, '$1' + ii(m.toString()))
36
+ formatted = formatted.replace(/(^|[^\\])m/g, '$1' + m)
37
+ if (timeFormat !== formatted) {
38
+ timeFormat = formatted
39
39
  seconds %= 60
40
40
  }
41
41
 
42
42
  s = seconds
43
- formated = format.replace(/(^|[^\\])ss+/g, '$1' + ii(s))
44
- formated = formated.replace(/(^|[^\\])s/g, '$1' + s)
43
+ formatted = timeFormat.replace(/(^|[^\\])ss+/g, '$1' + ii(s.toString()))
44
+ formatted = formatted.replace(/(^|[^\\])s/g, '$1' + s)
45
45
 
46
- return formated
46
+ return formatted
47
47
  }