Skip to content

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