Skip to content

Commit

Permalink
[ACS-5878] Migrated moment occurrences to date-fns equivalent in Proc…
Browse files Browse the repository at this point in the history
…essService (#8879)

* [ACS-5878] migrated moment to date-fns for ProcessService

* [ACS-5878] reverted variable renaming

* [ACS-5878] linting fixes
  • Loading branch information
SheenaMalhotra182 committed Sep 26, 2023
1 parent 3638ed0 commit 926347b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { ProcessInstanceVariable } from '../models/process-instance-variable.mod
import { ProcessService } from './process.service';
import { CoreModule } from '@alfresco/adf-core';
import { ProcessTestingModule } from '../../testing/process.testing.module';

declare let moment: any;
import { format } from 'date-fns';

describe('ProcessService', () => {
let service: ProcessService;
Expand Down Expand Up @@ -289,7 +288,7 @@ describe('ProcessService', () => {
const task = tasks[0];
expect(task.id).toBe(fakeTasks[0].id);
expect(task.name).toBe(fakeTasks[0].name);
expect(task.created).toEqual(moment(new Date('2016-11-10T00:00:00+00:00'), 'YYYY-MM-DD').format());
expect(task.created).toEqual(format(new Date('2016-11-10T00:00:00+00:00'), 'yyyy-MM-dd'));
done();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import { ProcessInstance } from '../models/process-instance.model';
import { ProcessListModel } from '../models/process-list.model';
import { map, catchError } from 'rxjs/operators';
import { DatePipe } from '@angular/common';

declare let moment: any;
import { format } from 'date-fns';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -214,7 +213,7 @@ export class ProcessService {
.pipe(
map(this.extractData),
map((tasks) => tasks.map((task: any) => {
task.created = moment(task.created, 'YYYY-MM-DD').format();
task.created = format(new Date(task.created), 'yyyy-MM-dd');
return task;
})),
catchError((err) => this.handleProcessError(err))
Expand Down Expand Up @@ -358,11 +357,11 @@ export class ProcessService {
return name;
}

private getFormatDate(value: Date, format: string) {
private getFormatDate(value: Date, dateFormat: string) {
const datePipe = new DatePipe('en-US');

try {
return datePipe.transform(value, format);
return datePipe.transform(value, dateFormat);
} catch (err) {
return '';
}
Expand Down

0 comments on commit 926347b

Please sign in to comment.