Update cycle count regularly
This commit is contained in:
parent
fffdccc7b8
commit
b7dbc597d8
4 changed files with 46 additions and 9 deletions
|
|
@ -4,6 +4,7 @@
|
|||
Icon,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import CycleCounter from '../components/CycleCounter.svelte';
|
||||
import DateFormat from '../components/DateFormat.svelte';
|
||||
import { getNextAlarm, newNCyclesAlarm } from '../lib/alarmsingle';
|
||||
import { alarmsSingle } from '../stores/alarmsingle';
|
||||
|
|
@ -11,11 +12,13 @@
|
|||
|
||||
let nextAlarmP = getNextAlarm();
|
||||
|
||||
function reloadNextAlarm() {
|
||||
nextAlarmP = getNextAlarm();
|
||||
alarmsSingle.clear();
|
||||
}
|
||||
|
||||
function newCyclesAlarm(ncycles) {
|
||||
newNCyclesAlarm(ncycles).then(() => {
|
||||
nextAlarmP = getNextAlarm();
|
||||
alarmsSingle.clear();
|
||||
})
|
||||
newNCyclesAlarm(ncycles).then(reloadNextAlarm);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -44,12 +47,12 @@
|
|||
aujourd'hui à
|
||||
<DateFormat date={nextalarm} timeStyle="long" />
|
||||
<br class="d-block d-md-none" />
|
||||
<span class="text-muted">(dans {Math.trunc((nextalarm.getTime()-Date.now())/5400000)} cycles + {Math.trunc(((nextalarm.getTime()-Date.now())%5400000)/60000)} min)</span>
|
||||
<CycleCounter ends={nextalarm} on:reload={reloadNextAlarm} />
|
||||
{:else if nextalarm.getDay() == new Date(Date.now() + 86400000).getDay() && nextalarm.getMonth() == new Date(Date.now() + 86400000).getMonth() && nextalarm.getFullYear() == new Date(Date.now() + 86400000).getFullYear()}
|
||||
demain à
|
||||
<DateFormat date={nextalarm} timeStyle="long" />
|
||||
<br class="d-block d-md-none" />
|
||||
<span class="text-muted">(dans {Math.trunc((nextalarm.getTime()-Date.now())/5400000)} cycles + {Math.trunc(((nextalarm.getTime()-Date.now())%5400000)/60000)} min)</span>
|
||||
<CycleCounter ends={nextalarm} on:reload={reloadNextAlarm} />
|
||||
{:else if nextalarm.getTime() < Date.now() + 604800000}
|
||||
<span title={nextalarm}>{nextalarm.toLocaleString('default', {weekday: 'long'})}</span>
|
||||
à
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue