I know the difference between EDT and EST is just in the Day Light Saving of 1 hour, but still I assume Rails treats it as different time zones, right?
Now, I have two time values, one in EDT zone and the other in IST. I need to convert both these time values to EST. I could do it successfully on IST time but not with EDT. How can I convert an EDT time to EST in Rails?
[36] pry(#<Quiz>)> Time.zone
=> (GMT-05:00) Eastern Time (US & Canada)
[37] pry(#<Quiz>)> from_date
=> 2015-03-02 00:00:00 +0530
[38] pry(#<Quiz>)> unlock_at
=> Mon, 16 Mar 2015 00:00:00 EDT -04:00
[39] pry(#<Quiz>)> from_date.in_time_zone
=> Sun, 01 Mar 2015 13:30:00 EST -05:00
[40] pry(#<Quiz>)> unlock_at.in_time_zone
=> Mon, 16 Mar 2015 00:00:00 EDT -04:00
Any help would be greatly appreciated :)
I know the difference between EDT and EST is just in the Day Light Saving of 1 hour, but still I assume Rails treats it as different time zones, right?
I wouldn't expect it to, no. They're not different time zones in themselves - they're just different parts of the Eastern time zone. It's unfortunate that there isn't an accepted term for this "part of a time zone" concept, as far as I'm aware.
Converting between EST and EDT doesn't generally make any sense - assuming that you're talking about a single time zone - because any one instant occurs either when EST is being observed or when EDT is observed. Talking about (say) "June 12th, 10am EST" is nonsensical (even though I know it happens) because EST isn't in effect in June. In human conversation, it's then unclear whether the speaker actually means UTC-5 (unaware of daylight saving time) or UTC-4 (unaware of the meaning of the S in EST).
It would only make some kind of sense if you've got two time zones, both of which are variants of Eastern, but which have different transition points. In that case, you should really just talk about converting between those two time zones.
Basically, the current output you've shown is entirely reasonable - you're converting two points in time into the Eastern time zone, and one falls in the period where that observes EST, and the other falls in the period where it observes EDT. You should not be trying to represent the latter in EST, as it doesn't exist at that point.
If you want to represent everything in a fixed offset of UTC-5, you should do that - but don't claim that it's EST.
See more on this question at Stackoverflow