@@ -15,13 +15,15 @@ export class TimeClockComponent implements OnInit {
1515 { id : 'P4' , name : 'Project 4' }
1616 ] ;
1717
18+ currentDate : Date = new Date ( ) ;
1819 username = 'Dario' ;
19- clockInUsername = 'hh:mm:ss' ;
20- clockOutUsername = 'hh:mm:ss' ;
2120 isClockIn : boolean ;
2221 isEnterTechnology : boolean ;
2322 showAlertEnterTecnology : boolean ;
2423 showFields : boolean ;
24+ hourCounterRealTime : number ;
25+ minuteCounterRealTime : number ;
26+ secondsCounterRealTime : number ;
2527 hour : number ;
2628 minute : number ;
2729 seconds : number ;
@@ -30,6 +32,9 @@ export class TimeClockComponent implements OnInit {
3032 constructor ( ) {
3133 this . isClockIn = true ;
3234 this . isEnterTechnology = false ;
35+ this . hourCounterRealTime = 0 ;
36+ this . minuteCounterRealTime = 0 ;
37+ this . secondsCounterRealTime = 0 ;
3338 this . hour = 0 ;
3439 this . minute = 0 ;
3540 this . seconds = 0 ;
@@ -38,6 +43,7 @@ export class TimeClockComponent implements OnInit {
3843 employeClockIn ( ) : boolean {
3944 this . isClockIn = ! this . isClockIn ;
4045 this . startTimer ( ) ;
46+ this . setTimeToInOut ( ) ;
4147 return this . isClockIn ;
4248 }
4349
@@ -50,6 +56,7 @@ export class TimeClockComponent implements OnInit {
5056 this . isEnterTechnology = false ;
5157 this . showAlertEnterTecnology = false ;
5258 this . pauseTimer ( ) ;
59+ this . setTimeToInOut ( ) ;
5360 }
5461 }
5562
@@ -73,21 +80,28 @@ export class TimeClockComponent implements OnInit {
7380 }
7481
7582 pauseTimer ( ) {
76- clearInterval ( this . interval ) ;
83+ clearInterval ( this . interval ) ;
7784 }
7885
7986 timer ( ) {
80- this . seconds += 1 ;
81- if ( this . seconds === 59 ) {
82- this . minute += 1 ;
83- this . seconds = 0 ;
84- if ( this . minute === 59 ) {
85- this . hour += 1 ;
86- this . minute = 0 ;
87+ this . secondsCounterRealTime += 1 ;
88+ if ( this . secondsCounterRealTime === 59 ) {
89+ this . minuteCounterRealTime += 1 ;
90+ this . secondsCounterRealTime = 0 ;
91+ if ( this . minuteCounterRealTime === 59 ) {
92+ this . hourCounterRealTime += 1 ;
93+ this . minuteCounterRealTime = 0 ;
8794 }
8895 }
8996 }
9097
98+ setTimeToInOut ( ) {
99+ this . currentDate = new Date ( ) ;
100+ this . hour = this . currentDate . getHours ( ) ;
101+ this . minute = this . currentDate . getMinutes ( ) ;
102+ this . seconds = this . currentDate . getSeconds ( ) ;
103+ }
104+
91105 ngOnInit ( ) : void { }
92106
93107}
0 commit comments