With 1.9.2p0, Date#parse assumes an UE format. Check out format.rb, line: 1042 if you don't believe me.
Anyways, how can I make it assume a US format, so that:
> Date.parse("10/4/2010")
=> Mon, 04 Oct 2010
Instead of April 10th.
I've tried this:
class Date
def _parse_eu(str,e)
_parse_us(str,e)
end
end
but no luck. Any other ideas?
: to cause someone's day to be pleasant or happy Thanks for the compliment. You've really made my day!
Date is defined as a particularly day of the month or day, month and year or a social outing between two people. An example of date is October 9, 1925. An example of date is two people meeting for coffee.
This, in a nutshell, is the art of 'friend dating'. The premise of friend dating is this: if we like the thought of being mates with someone, we should actively pursue and nurture a relationship with them, much in the same way we might treat a potential romantic partner.
nounarrangement for meeting; prearranged meeting. assignation. assignment. blind date. consultation.
Date.strptime is what you want but unfortunately it doesn't look like the documentation has the date formatting strings. I got the following to work based on Googling for the format strings:
1.9.2 > d = Date.strptime("10/4/2010", "%m/%d/%Y")
=> #<Date: 2010-10-04 (4910947/2,0,2299161)>
1.9.2 > d.day
=> 4
1.9.2 > d = Date.strptime("10/4/2010", "%d/%m/%Y")
=> #<Date: 2010-04-10 (4910593/2,0,2299161)>
1.9.2 > d.day
=> 10
You might want to check out strptime instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With