I do not mean
myDateTime = DateTime.now myDateTime.new_offset(Rational(0, 24))
or
Time.now.utc
What I have is a text date indicated in Eastern Time.
I can convert this text date to DateTime. Let me call it eastern_date_time .
Now we have a variable containing DateTime, but nothing knows it east, except for us. Converting it in itself would be very burdensome. If the date is summer time savings (DST) (from March 8 to November 1 of this year), we must add 4 hours to our east_time_time var to get UTC, and if the date is in standard time (ST), we would need to add 5 hours to our east_date_time variable.
How can we indicate that what we have is an Eastern DateTime, and then convert it to UTC ... something that will determine if the date is in DST / ST, and whether itβs correctly applied for 4 or 5 hours?
I want to convert any date that I receive in UTC to be stored in my database.
EDIT:
Using `in_time_zone ', I cannot convert my eastern text time to UTC. How can I achieve this? For instance...
text_time = "Nov 27, 2015 4:30 PM"
This is not what we want. We must indicate that myEasterDateTime is actually oriental ... so when we do myEasterDateTime.utc at 16:30:00, we get 20:30:00.
How can i do this?
source share