Skip to content

Commit a741fb6

Browse files
authored
fix: TT-328 when editing/creating entries set seconds to 0 (#744)
* fix: TT-328 when editing/creating entries set seconds to 0 * refactor: TT-328 rename of certain variable to make the code more readable * fix: TT-328 standarize entry-miliseconds to 0 * refactor: TT-328 remove redundant pieces of code
1 parent 8d3ca3f commit a741fb6

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,18 @@ describe('TimeEntriesComponent', () => {
381381
it('should preload data of last entry when a project is selected while creating new entry ', waitForAsync(() => {
382382
component.entry = null;
383383
component.entryId = null;
384+
const defaultSeconds = 0;
385+
const currentDate = new Date();
386+
currentDate.setSeconds(defaultSeconds);
387+
currentDate.setMilliseconds(defaultSeconds);
384388
const lastEntry = {
385389
description: 'testing is fun',
386390
technologies: [],
387391
uri: 'http://testing.is.fun',
388392
activity_id: 'sss',
389393
project_id: 'id',
390-
start_date: new Date(),
391-
end_date: new Date(new Date().setHours(0, 0, 0, 0))
394+
start_date: currentDate,
395+
end_date: currentDate
392396
};
393397
state.timeEntriesDataSource.data = [lastEntry];
394398
mockEntriesSelector = store.overrideSelector(getTimeEntriesDataSource, state.timeEntriesDataSource);

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,18 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
139139
this.store.pipe(select(getTimeEntriesDataSource)).subscribe(ds => {
140140
const dataToUse = ds.data.find(item => item.project_id === event.projectId);
141141
if (dataToUse && this.isNewEntry()) {
142-
const startDate = new Date(new Date().setHours(0, 0, 0, 0));
142+
const defaultSeconds = 0;
143+
const currentDate = new Date();
144+
currentDate.setSeconds(defaultSeconds);
145+
currentDate.setMilliseconds(defaultSeconds);
143146
const entry = {
144147
description: dataToUse.description ? dataToUse.description : '',
145148
technologies: dataToUse.technologies ? dataToUse.technologies : [],
146149
uri: dataToUse.uri ? dataToUse.uri : '',
147150
activity_id: dataToUse.activity_id,
148151
project_id: dataToUse.project_id,
149-
start_date: new Date(),
150-
end_date: startDate
152+
start_date: currentDate,
153+
end_date: currentDate
151154
};
152155
this.entry = entry;
153156
}

0 commit comments

Comments
 (0)