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

last day of the month #26

Closed
rurounijones opened this issue Dec 3, 2010 · 13 comments
Closed

last day of the month #26

rurounijones opened this issue Dec 3, 2010 · 13 comments
Labels

Comments

@rurounijones
Copy link

I am trying to find a way of getting the last day of a month, for example: last day of last month

I have tried various combos but cannot find anything. I have had a look through the code and it is a bit beyond me. Does anyone know if this can be done?

I should mention that the first day works. Something like "last month first day" or "first day of last month" is fine.

@leejarvis
Copy link
Collaborator

There's currently no way of interpreting last as the end of a month. Chronic doesn't contain a month day lookup table except for when constructing Time objects, which is too low level for this. I've labeled this as a feature though, I think it's a great idea.

@jeremywadsack
Copy link

How about last day of a month is first day of the next month minus one day? In other words, use the month day lookup that's built into ruby / the OS.

@rurounijones
Copy link
Author

That is what I ended up doing for that particular case instead of usng Chronic.

@leejarvis
Copy link
Collaborator

@jeremywadsack Yeah that was my intention for this. Just haven't found time to get around to it yet.

@semperos
Copy link

It would also be great to have "Last Monday in May" logic (this is US Memorial Day).

@tamouse
Copy link

tamouse commented Dec 1, 2012

+1 for last weekday of month. Currently doing this:

d = ((x = Chronic::parse("fifth Monday in May")).nil?) ? (Chronic::parse("fourth Monday in May)) : x

@jaredbrown
Copy link

+1 for last weekday of month

@timfong888
Copy link

+1 last day of the month

2 similar comments
@kovpack
Copy link

kovpack commented Apr 4, 2016

+1 last day of the month

@shrav
Copy link

shrav commented Apr 22, 2016

+1 last day of the month

@zedtux
Copy link

zedtux commented Feb 8, 2017

+1

@zedtux
Copy link

zedtux commented Feb 8, 2017

Here is how I did it based on @jeremywadsack's comment:

Chronic.parse('1st day next month') - 1.day

@ghost
Copy link

ghost commented Feb 14, 2019

This is a much needed feature... any ETA?

My use case: "Last day of next month"

Expected: If today is 14 Feb 2019 -> 31 March 2019

@rurounijones rurounijones closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants