Fix countdown

master
Nikola Forró 6 years ago
parent 8b9e4892ff
commit b0f957c0fc

@ -14,12 +14,11 @@ export class GetDateTimePipe implements PipeTransform {
transform(slot: Slot): Date {
let result = new Date();
let day = WEEKDAYS.indexOf(slot.label.toLowerCase());
result.setUTCHours(0, 0, 0, 0);
result.setDate(result.getDate() + day - result.getDay());
let remainder = slot.offset % 60;
result.setUTCHours(slot.hours - (slot.offset - remainder) / 60 >> 0);
result.setUTCMinutes(slot.minutes - remainder);
result.setUTCSeconds(0);
result.setUTCMilliseconds(0);
if (result.getTime() < Date.now()) {
result.setDate(result.getDate() + 7);
}

Loading…
Cancel
Save