Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DatePipe): should handle empty string #12374

Merged
merged 1 commit into from
Nov 8, 2016

Conversation

DzmitryShylovich
Copy link
Contributor

@DzmitryShylovich DzmitryShylovich commented Oct 18, 2016

Fixes #12368

@DzmitryShylovich DzmitryShylovich force-pushed the feature/12373 branch 3 times, most recently from b495ee4 to 36f8609 Compare October 18, 2016 19:26
@pkozlowski-opensource pkozlowski-opensource added the area: common Issues related to APIs in the @angular/common package label Oct 19, 2016
@vicb
Copy link
Contributor

vicb commented Oct 20, 2016

lgtm, please rebase for the CI to turn green. Thanks for one more PR !

@vicb vicb added the action: merge The PR is ready for merge by the caretaker label Oct 20, 2016
@vicb
Copy link
Contributor

vicb commented Oct 20, 2016

Thanks !

@@ -95,22 +95,25 @@ export class DatePipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private _locale: string) {}

transform(value: any, pattern: string = 'mediumDate'): string {
if (isBlank(value)) return null;
if (!value) return null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is going to happen for 0? Isn't it a valid numeric argument?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right please use value == null instead

Copy link
Contributor Author

@DzmitryShylovich DzmitryShylovich Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that. What would u expect to get for 0?
Thu Jan 01 1970

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that. What would u expect to get for 0?

Same as for new Date(0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, fixed.

@vicb vicb removed the action: merge The PR is ready for merge by the caretaker label Oct 20, 2016
}
}

function isBlank(obj: any): boolean {
return obj === undefined || obj === null || obj === '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline: obj == null || obj === ''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DzmitryShylovich would you mind doing the change @vicb requested so we can merge this one? Thnx!

@vicb vicb added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Oct 29, 2016
@DzmitryShylovich
Copy link
Contributor Author

@vicb done

@pkozlowski-opensource pkozlowski-opensource added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Nov 8, 2016
@vikerman vikerman merged commit 3dc6177 into angular:master Nov 8, 2016
@DzmitryShylovich DzmitryShylovich deleted the feature/12373 branch November 8, 2016 23:45
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Date Pipe does not handle empty date string
5 participants