File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,11 @@ export class TimeClockComponent implements OnInit {
2121 isClockIn : boolean ;
2222 isEnterTechnology : boolean ;
2323 showAlertEnterTecnology : boolean ;
24-
24+ showFields : boolean ;
2525 hour : number ;
2626 minute : number ;
2727 seconds : number ;
28-
29- showFields : boolean ;
28+ interval ;
3029
3130 constructor ( ) {
3231 this . isClockIn = true ;
@@ -38,6 +37,7 @@ export class TimeClockComponent implements OnInit {
3837
3938 employeClockIn ( ) : boolean {
4039 this . isClockIn = ! this . isClockIn ;
40+ this . startTimer ( ) ;
4141 return this . isClockIn ;
4242 }
4343
@@ -49,6 +49,7 @@ export class TimeClockComponent implements OnInit {
4949 this . isClockIn = true ;
5050 this . isEnterTechnology = false ;
5151 this . showAlertEnterTecnology = false ;
52+ this . pauseTimer ( ) ;
5253 }
5354 }
5455
@@ -65,6 +66,28 @@ export class TimeClockComponent implements OnInit {
6566 this . showFields = show ;
6667 }
6768
69+ startTimer ( ) {
70+ this . interval = setInterval ( ( ) => {
71+ this . timer ( ) ;
72+ } , 1000 ) ;
73+ }
74+
75+ pauseTimer ( ) {
76+ clearInterval ( this . interval ) ;
77+ }
78+
79+ 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+ }
88+ }
89+ }
90+
6891 ngOnInit ( ) : void { }
6992
7093}
You can’t perform that action at this time.
0 commit comments