Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6775 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6775 Rev 6911
Línea 23... Línea 23...
23
  const month = date.toLocaleString('es-ES', { month: 'long' })
23
  const month = date.toLocaleString('es-ES', { month: 'long' })
Línea 24... Línea 24...
24
 
24
 
25
  return month
25
  return month
Línea -... Línea 26...
-
 
26
}
-
 
27
 
-
 
28
const DATE_UNITS = {
-
 
29
  year: 31557600,
-
 
30
  month: 2628000,
-
 
31
  day: 86000,
-
 
32
  hour: 3600,
-
 
33
  minute: 60,
-
 
34
  second: 1,
-
 
35
}
-
 
36
 
-
 
37
const rft = new Intl.RelativeTimeFormat('en', { numeric: 'auto' })
-
 
38
 
-
 
39
const getRelativeTime = (time) => {
-
 
40
  const started = new Date(time + 1000).getTime()
-
 
41
  const now = new Date().getTime()
-
 
42
 
-
 
43
  const elapsed = (started - now) / 1000
-
 
44
 
-
 
45
  for (const unit in DATE_UNITS) {
-
 
46
    const absoluteElapsed = Math.abs(elapsed)
-
 
47
 
-
 
48
    if (absoluteElapsed > DATE_UNITS[unit] || unit === 'second') {
-
 
49
      return rft.format(Math.floor(elapsed / DATE_UNITS[unit]), unit)
-
 
50
    }
-
 
51
  }
-
 
52
 
-
 
53
  return ''
26
}
54
}