@@ -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' ;
2222import { TechnologiesComponent } from '../technologies/technologies.component' ;
2323
2424type Merged = TechnologyState & ProjectState & ActivityState & EntryState ;
@@ -131,23 +131,16 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
131131 }
132132
133133 getTimeDifference ( ) {
134- moment . locale ( 'es' ) ;
135- const hourStart = this . start_hour . value ;
136- const hourEnd = this . end_hour . value ;
137- const ab = moment ( hourStart , 'HH:mm' ) ;
138- const ac = moment ( hourEnd , 'HH:mm' ) ;
139- if ( hourStart === '00:00' ) {
140- const hourTotal = '00:00' ;
141- return hourTotal ;
142- }
143- if ( hourEnd === '00:00' ) {
144- const hourTotal = '00:00' ;
145- return hourTotal ;
146- } else {
147- const hourTotal = [ moment . duration ( ab . diff ( ac ) ) ] ;
148- return hourTotal ;
134+ const startDate = moment ( `${ this . start_date . value } ${ this . start_hour . value } ` ) . format ( DATE_FORMAT_HOUR ) ;
135+ const endDate = moment ( `${ this . end_date . value } ${ this . end_hour . value } ` ) . format ( DATE_FORMAT_HOUR ) ;
136+ if ( this . end_hour . value !== '00:00' ) {
137+ const diffDate = moment ( endDate , DATE_FORMAT_HOUR ) . diff ( moment ( startDate , DATE_FORMAT_HOUR ) ) ;
138+ const duration = moment . duration ( diffDate ) ;
139+ const diferenceTime = Math . floor ( duration . asHours ( ) ) + moment . utc ( diffDate ) . format ( ':mm' ) ;
140+ return diferenceTime ;
141+ } else {
142+ return '0:00' ;
149143 }
150-
151144 }
152145
153146 ngOnChanges ( ) : void {
0 commit comments