ruby/ruby — pull request #540 by sferik (2014-02-19 12:26:34+00:00)
Title: Improvements to Time::strptime

This pull request includes three commits:

* [Add default arguments to `Time::strptime` to match `Date::strptime`.](https://github.com/sferik/ruby-1/commit/b0b88f80b8fb10b113e67f166db4ff30c1ada94d) After this patch, `Time::strptime` may be invoked with 0, 1, or 2 arguments. When invoked with 0 or 1, it produces a result equivalent to `Date::strptime` invoked with the same arguments.
* [Raise ArgumentError if time passed to `Time::strptime` is invalid.](https://github.com/sferik/ruby-1/commit/aaf7ad041eab2a4472963a4e8adee7132d59dd72) This fixes a Ruby bug and adds a test to ensure it will not regress. Before this commit:
```ruby
require 'date'
Date::strptime('31/02/2014', '%d/%m/%Y') # ArgumentError: invalid date
require 'time'
Time::strptime('31/02/2014', '%d/%m/%Y') # 2014-03-03 00:00:00 +0000
```
* I have also [renamed variables in `Time::parse` to be consistent with the changes I made to `Time::strptime`](https://github.com/sferik/ruby-1/commit/53a34735c15c663aeb86f36560fde819b1c100b9). Specifically, renaming `d` to `hash`, since it is not a `Date` and renaming the `date` parameter to `time`. I believe both of these changes make the code clearer.

Thank you for considering this patch.