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

[feature request] Add helper to set last day of month #731

Closed
everdimension opened this issue Nov 12, 2019 · 3 comments
Closed

[feature request] Add helper to set last day of month #731

everdimension opened this issue Nov 12, 2019 · 3 comments

Comments

@everdimension
Copy link

everdimension commented Nov 12, 2019

Hello! Thanks a lot for this library.

I stumbled upon a case where I need to be able to set a "maximum" date for the current month. E.g.

dayjs().set('date', 'max'); // is it 30 or 31 or 28? I wish I could just tell the lib to pick the right one

What do you think? If you agree that it is a good idea I'd be glad to make a PR.
But I think the exact API should be discussed first.

Thanks!

@everdimension
Copy link
Author

Oh, well, I just realized I can do this:

dayjs().set('date', 1).add(1, 'month').subtract(1, 'day');

:)

@iamkun
Copy link
Owner

iamkun commented Nov 13, 2019

You can use

dayjs().endOf('month')

@everdimension
Copy link
Author

Oh, thanks!! Did not find that. I guess the issue is solved, then

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

No branches or pull requests

2 participants