parent
79aacd731a
commit
9402662281
@ -1,10 +0,0 @@
|
||||
export interface Slot {
|
||||
label: string;
|
||||
uuid: string;
|
||||
description: string;
|
||||
isEnabled: boolean;
|
||||
isTimeEnabled: boolean;
|
||||
hours: number;
|
||||
minutes: number;
|
||||
offset: number;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
import {
|
||||
Pipe,
|
||||
PipeTransform
|
||||
} from '@angular/core';
|
||||
|
||||
import { Slot } from '../models/slot';
|
||||
|
||||
|
||||
@Pipe({
|
||||
name: 'getdatetime'
|
||||
})
|
||||
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);
|
||||
if (result.getTime() < Date.now()) {
|
||||
result.setDate(result.getDate() + 7);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
const WEEKDAYS = [
|
||||
'sunday',
|
||||
'monday',
|
||||
'tuesday',
|
||||
'wednesday',
|
||||
'thursday',
|
||||
'friday',
|
||||
'saturday'
|
||||
];
|
Loading…
Reference in new issue