aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/api/batterymanager/dischargingtime/index.md
blob: f9534a5fd3264c912c5e18e792524b9c28900cfb (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: BatteryManager.dischargingTime
slug: Web/API/BatteryManager/dischargingTime
tags:
  - API
  - Apps
  - Batería
  - Battery
  - Firefox OS
  - Gecko DOM Reference
  - WebAPI
  - aplicaciones
translation_of: Web/API/BatteryManager/dischargingTime
browser-compat: api.BatteryManager.dischargingTime
---
{{deprecated_header}}{{APIRef("Battery API")}}

Indíca la cantidad de tiempo, en segundos,
que restan antes de que la batería se descargue completamente.

> **Nota:** Incluso si el tiempo devuelto es exacto al segundo, los navegadores los redondean a un intervalo más alto (típicamente a los 15 minutos más cercanos) por razones de privacidad.

## Sintaxis

```js
var time = battery.dischargingTime;
```

Valor de retorno, `time` es el tiempo restante en segundos antes que la `battery`,
que es un objeto {{domxref("BatteryManager")}},
esté completamente descargada y el sistema se suspenda.
Este valor es [`Infinity`](/es/docs/Web/JavaScript/Reference/Global_Objects/Infinity)
Si la batería se está cargando en vez de descargando,
o si el sistema es incapaz de calcular el tiempo de descarga.

## Ejemplo

### Contenido HTML

```html
<div id="dischargingTime">(tiempo de descarga desconocido)</div>
```

### Contenido JavaScript

```js
navigator.getBattery().then(function(battery) {
  var time = battery.dischargingTime;

  document.querySelector("#dischargingTime").textContent = battery.dischargingTime;
});
```

### Resultado

{{EmbedLiveSample('', '100%', 30)}}

## Especificaciones

{{Specifications}}

## Compatibilidad del navegador

{{Compat}}

## Ver también

- {{domxref("BatteryManager")}}
- {{domxref("Navigator.getBattery")}}