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 ex2 #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix ex2 #11

wants to merge 2 commits into from

Conversation

Runekid
Copy link

@Runekid Runekid commented May 31, 2024

No description provided.

it('should return "1 year ago" for a date less than 2 years ago', () => {
const date = new Date(Date.now() - 13 * 30 * 24 * 60 * 60 * 1000); // 13 months ago
expect(pipe.transform(date)).toBe('about 1 year ago');
});
Copy link
Member

Choose a reason for hiding this comment

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

Oh my, nice!

// N yrs 3 months ... N yrs 9 months -> over N years
// N yrs 9 months ... N+1 yrs -> almost N+1 years

transform(value: Date): string {
Copy link
Member

Choose a reason for hiding this comment

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

fyi (pas dit niet aan, focus op de Angular;)

you could maybe accept string | Date | number

string --> ISODate string
number --> from epoch

Dankzij deze zou dat dan blijven werken

const date = new Date(value);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants