@@ -18,7 +18,7 @@ import { EntryActionTypes } from './../../../time-clock/store/entry.actions';
1818import { SaveEntryEvent } from './save-entry-event' ;
1919import { ProjectSelectedEvent } from './project-selected-event' ;
2020import { get } from 'lodash' ;
21- import { DATE_FORMAT } from 'src/environments/environment' ;
21+ import { DATE_FORMAT , DATE_FORMAT_HOUR } from 'src/environments/environment' ;
2222
2323type Merged = TechnologyState & ProjectState & ActivityState & EntryState ;
2424@Component ( {
@@ -129,23 +129,16 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
129129 }
130130
131131 getTimeDifference ( ) {
132- moment . locale ( 'es' ) ;
133- const hourStart = this . start_hour . value ;
134- const hourEnd = this . end_hour . value ;
135- const ab = moment ( hourStart , 'HH:mm' ) ;
136- const ac = moment ( hourEnd , 'HH:mm' ) ;
137- if ( hourStart === '00:00' ) {
138- const hourTotal = '00:00' ;
139- return hourTotal ;
140- }
141- if ( hourEnd === '00:00' ) {
142- const hourTotal = '00:00' ;
143- return hourTotal ;
144- } else {
145- const hourTotal = [ moment . duration ( ab . diff ( ac ) ) ] ;
146- return hourTotal ;
132+ const startDate = moment ( `${ this . start_date . value } ${ this . start_hour . value } ` ) . format ( DATE_FORMAT_HOUR ) ;
133+ const endDate = moment ( `${ this . end_date . value } ${ this . end_hour . value } ` ) . format ( DATE_FORMAT_HOUR ) ;
134+ if ( this . end_hour . value !== '00:00' ) {
135+ const diffDate = moment ( endDate , DATE_FORMAT_HOUR ) . diff ( moment ( startDate , DATE_FORMAT_HOUR ) ) ;
136+ const duration = moment . duration ( diffDate ) ;
137+ const diferenceTime = Math . floor ( duration . asHours ( ) ) + moment . utc ( diffDate ) . format ( ':mm' ) ;
138+ return diferenceTime ;
139+ } else {
140+ return '0:00' ;
147141 }
148-
149142 }
150143
151144 ngOnChanges ( ) : void {
0 commit comments