diff --git a/src/app/components/noosfero/date-format/date-format.filter.spec.ts b/src/app/components/noosfero/date-format/date-format.filter.spec.ts index 2d9ff18..88d699c 100644 --- a/src/app/components/noosfero/date-format/date-format.filter.spec.ts +++ b/src/app/components/noosfero/date-format/date-format.filter.spec.ts @@ -5,12 +5,13 @@ describe("Filters", () => { describe("Date Format Filter", () => { beforeEach(angular.mock.module("templates")); + beforeEach(angular.mock.module("angularMoment")); it("convert date from the format returned by noosfero api to an ISO format", done => { let date = "2016/03/10 10:46:47"; let htmlTemplate = `{{ '${date}' | dateFormat }}`; quickCreateComponent({ providers: [DateFormat], template: htmlTemplate }).then(fixture => { - expect(fixture.debugElement.text()).toEqual('"2016-03-10T13:46:47.000Z"'); + expect(fixture.debugElement.text()).toEqual('2016-03-10T13:46:47.000Z'); done(); }); }); diff --git a/src/app/components/noosfero/date-format/date-format.filter.ts b/src/app/components/noosfero/date-format/date-format.filter.ts index 84bc18d..00ffa4d 100644 --- a/src/app/components/noosfero/date-format/date-format.filter.ts +++ b/src/app/components/noosfero/date-format/date-format.filter.ts @@ -1,10 +1,13 @@ import {Pipe, Inject} from "ng-forward"; @Pipe("dateFormat") +@Inject("amParseFilter") export class DateFormat { + constructor(private amParseFilter: any) { } + transform(date: string, options: any) { - return moment(date, "YYYY/MM/DD HH:mm:ss"); + return this.amParseFilter(date, "YYYY/MM/DD HH:mm:ss").toISOString(); } } -- libgit2 0.21.2