I'm using the Rspotify gem and trying to compare the date I get back for a given album (i.e. album.release_date
) with the current user's last sign in date (i.e. current_user.last_sign_in_at
). The release_date
is a string.
Example album release date: "2017-03-18"
Example last sign in date: Sat, 13 May 2017 18:57:28 UTC +00:00
I've looked at and tried every solution I could find online, including:
- Various string to date methods (e.g.
DateTime()
,.to_time
, etc.) - Converting the string to a date and then both dates to integers
- Adding a time zone
But I keep running into a couple errors.
The two most common errors I get are argument out of range
and invalid date
. I'm further confused because, in the console when using byebug, I'm able to compare the two dates with a few different conversion methods.