Skip to content
Next Next commit
timer working
Clock component
  • Loading branch information
daros10 committed Mar 19, 2020
commit ba7f7d5d6e7de50e8adeeee3d10ac56d1b4e2409
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ export class TimeClockComponent implements OnInit {
isClockIn: boolean;
isEnterTechnology: boolean;
showAlertEnterTecnology: boolean;

showFields: boolean;
hour: number;
minute: number;
seconds: number;

showFields: boolean;
interval;

constructor() {
this.isClockIn = true;
Expand All @@ -38,6 +37,7 @@ export class TimeClockComponent implements OnInit {

employeClockIn(): boolean {
this.isClockIn = !this.isClockIn;
this.startTimer();
return this.isClockIn;
}

Expand All @@ -49,6 +49,7 @@ export class TimeClockComponent implements OnInit {
this.isClockIn = true;
this.isEnterTechnology = false;
this.showAlertEnterTecnology = false;
this.pauseTimer();
}
}

Expand All @@ -65,6 +66,28 @@ export class TimeClockComponent implements OnInit {
this.showFields = show;
}

startTimer() {
this.interval = setInterval(() => {
this.timer();
}, 1000 );
}

pauseTimer() {
clearInterval(this.interval);
}

timer() {
this.seconds += 1;
if ( this.seconds === 59 ) {
this.minute += 1;
this.seconds = 0;
if ( this.minute === 59 ) {
this.hour += 1;
this.minute = 0;
}
}
}

ngOnInit(): void {}

}