github.com/oinume/lekcije@v0.0.0-20231017100347-5b4c5eb6ab24/frontend/src/models/NotificatonTimeSpan.ts (about)

     1  // TODO: Add method isZero() and parse().
     2  type MaybeNotificationTimeSpan = {
     3    fromHour: number;
     4    fromMinute: number;
     5    toHour: number;
     6    toMinute: number;
     7  };
     8  
     9  export class NotificationTimeSpanModel {
    10    [key: string]: any
    11  
    12    static fromObject(o: MaybeNotificationTimeSpan): NotificationTimeSpanModel {
    13      return new NotificationTimeSpanModel(o.fromHour, o.fromMinute, o.toHour, o.toMinute);
    14    }
    15  
    16    constructor(
    17      public fromHour: number,
    18      public fromMinute: number,
    19      public toHour: number,
    20      public toMinute: number,
    21    ) {}
    22  
    23    isZero(): boolean {
    24      return this.fromHour === 0 && this.fromMinute === 0 && this.toHour === 0 && this.toMinute === 0;
    25    }
    26  }