diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts index c69d23912..2ffda6571 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.spec.ts @@ -207,7 +207,8 @@ describe('DetailsFieldsComponent', () => { description: '', start_date: new Date('2020-02-05T00:00:01').toISOString(), end_date: new Date('2020-02-05T00:01:01').toISOString(), - uri: '' + uri: '', + timezone_offset: new Date().getTimezoneOffset(), }, shouldRestartEntry: false }; @@ -276,6 +277,7 @@ describe('DetailsFieldsComponent', () => { description: '', start_date: new Date('2020-06-11T00:00:10').toISOString(), uri: 'ticketUri', + timezone_offset: new Date().getTimezoneOffset(), }, shouldRestartEntry: false }; diff --git a/src/app/modules/shared/components/details-fields/details-fields.component.ts b/src/app/modules/shared/components/details-fields/details-fields.component.ts index 4e999be2e..d6dbc7aa7 100644 --- a/src/app/modules/shared/components/details-fields/details-fields.component.ts +++ b/src/app/modules/shared/components/details-fields/details-fields.component.ts @@ -165,6 +165,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { start_date: new Date(`${entryDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(), end_date: new Date(`${entryDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(), uri: this.entryForm.value.uri, + timezone_offset: new Date().getTimezoneOffset(), }; if (this.goingToWorkOnThis) { delete entry.end_date; diff --git a/src/app/modules/shared/models/entry.model.ts b/src/app/modules/shared/models/entry.model.ts index 51f8eb926..134b3dd7f 100644 --- a/src/app/modules/shared/models/entry.model.ts +++ b/src/app/modules/shared/models/entry.model.ts @@ -18,4 +18,5 @@ export interface NewEntry { technologies?: string[]; uri?: string; activity_id?: string; + timezone_offset?: number; } diff --git a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts index 801e05a86..5abcd4dce 100644 --- a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts +++ b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.spec.ts @@ -118,4 +118,17 @@ describe('ProjectListHoverComponent', () => { expect(component.projectsForm.setValue) .toHaveBeenCalledWith({ project_id: 'customer - xyz'}); }); + + it('creates time-entry with timezone_offset property', () => { + spyOn(store, 'dispatch'); + component.clockIn('1', 'customer', 'project'); + expect(store.dispatch).toHaveBeenCalledWith( + new CreateEntry({ + project_id: '1', + start_date: new Date().toISOString(), + timezone_offset: new Date().getTimezoneOffset() + }) + ); + }); + }); diff --git a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts index f810a29f4..1680951c2 100644 --- a/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts +++ b/src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts @@ -78,7 +78,11 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy { } clockIn(selectedProject, customerName, name) { - const entry = { project_id: selectedProject, start_date: new Date().toISOString() }; + const entry = { + project_id: selectedProject, + start_date: new Date().toISOString(), + timezone_offset: new Date().getTimezoneOffset(), + }; this.store.dispatch(new entryActions.CreateEntry(entry)); this.projectsForm.setValue( { project_id: `${customerName} - ${name}`, } ); } diff --git a/src/app/modules/time-clock/store/entry.effects.ts b/src/app/modules/time-clock/store/entry.effects.ts index 2a649b07f..c8020ea79 100644 --- a/src/app/modules/time-clock/store/entry.effects.ts +++ b/src/app/modules/time-clock/store/entry.effects.ts @@ -21,7 +21,11 @@ export class EntryEffects { map((response) => { const stopDateForEntry = new Date(response.end_date); stopDateForEntry.setSeconds(stopDateForEntry.getSeconds() + 1 ); - return new actions.CreateEntry({ project_id: action.idProjectSwitching, start_date: stopDateForEntry.toISOString() }); + return new actions.CreateEntry({ + project_id: action.idProjectSwitching, + start_date: stopDateForEntry.toISOString(), + timezone_offset: new Date().getTimezoneOffset(), + }); }), catchError((error) => { this.toastrService.warning(error.error.message); diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts index 00d6ded42..29b9f4591 100644 --- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts +++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts @@ -146,7 +146,8 @@ describe('TimeEntriesComponent', () => { entry: { project_id: 'project-id', end_date: '2010-05-05T10:04', - start_date: null + start_date: null, + timezone_offset: 300, }, shouldRestartEntry: false }; component.activeTimeEntry = null; @@ -303,6 +304,7 @@ describe('TimeEntriesComponent', () => { description: 'description', technologies: [], uri: 'abc', + timezone_offset: 300, }, shouldRestartEntry: false }; component.entryId = undefined;