Last day in month

Hi,

i’m trying to get the last day of a month with chronic. Since chronic
seems to use ‘last’ as keyword in a sence like “back from now” this
does’t give a result

Chronic.parse(“last day of this month”)

i tried also ‘latest’ and ‘end’ instead of ‘last’ with no result. I
couldn’t find an appropriate example in the documentation
http://chronic.rubyforge.org/ , neither i could find an exact
documentation of all valid keywords.

Any hints?

Thx for any help
Regards
Daniel

On Jan 25, 2007, at 4:45 PM, Daniel L. wrote:

chronic.rubyforge.org/ , neither i could find an exact
documentation of all valid keywords.

Any hints?

Just guessing, but you might try “day before 1st day of next month”.

Regards, Morton

On Jan 25, 3:53 pm, Morton G. [email protected] wrote:

On Jan 25, 2007, at 4:45 PM, Daniel L. wrote:

i’m trying to get the last day of a month with chronic. Since
chronic seems to use ‘last’ as keyword in a sence like “back from
now” this does’t give a result
Any hints?

Just guessing, but you might try “day before 1st day of next month”.

Close:
irb(main):005:0> Chronic.parse( ‘1 day before first day of January’)
=> Sun Dec 31 12:00:00 -0700 2006

i’m trying to get the last day of a month with chronic.

The natural language processing of chronic is sweet, but if all you need
is the last day of a month, you could do this:

C:>gem install expanded_date
Successfully installed expanded_date-0.2.1
Installing ri documentation for expanded_date-0.2.1…
Installing RDoc documentation for expanded_date-0.2.1…

C:>irb
irb(main):001:0> require ‘expanded_date’
=> true

irb(main):002:0> d = Date.today
=> #<Date: 4908255/2,0,2299161>

irb(main):003:0> d.to_s
=> “2007-01-27”

irb(main):004:0> d.end_of_month.to_s
=> “2007-01-31”

irb(main):005:0> d.end_of_next_month.to_s
=> “2007-02-28”

irb(main):006:0> d.end_of_prev_month.to_s
=> “2006-12-31”

All the best

Daniel L. wrote:

http://chronic.rubyforge.org/ , neither i could find an exact
documentation of all valid keywords.

Any hints?

Thx for any help
Regards
Daniel

Chronic.parse(‘1 day before next month’, {:guess => false})
=> Wed Jan 31 00:00:00 -0800 2007…Wed Feb 28 00:00:00 -0800 2007

Chronic.parse(‘1 day before next month’, {:guess => false}).begin
=> Wed Jan 31 00:00:00 -0800 2007

Which is a little weird because generally you’re not asking for
distances in smaller units than the anchor, but it still works. =)

Tom

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs