Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3627444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:53:22+00:00 2026-05-18T23:53:22+00:00

Consider this gist: https://gist.github.com/752934 When converting from String to Time everything goes well. It

  • 0

Consider this gist: https://gist.github.com/752934

When converting from String to Time everything goes well. It returns as UTC. However, when you convert from time to time it returns as WEST instead of UTC (or returning self: http://api.rubyonrails.org/classes/Time.html#method-i-to_time)

Any idea on why is the time zone being changed from UTC to WEST?

Thanks in advance,
DBA

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:53:22+00:00Added an answer on May 18, 2026 at 11:53 pm

    I am guessing it suffers from the same problem as DateTime.to_time. This was submitted as a bug in Ruby, but rejected. More info here:

    http://redmine.ruby-lang.org/issues/show/3737

    UPDATE:
    https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/time/conversions.rb

    Looks like API doc is out of date. There is a condition on the method to check if to_time is already defined. So looks like its not even hitting this ext method:

      # A method to keep Time, Date and DateTime instances interchangeable on conversions.
      # In this case, it simply returns +self+.
      def to_time
        self
      end unless method_defined?(:to_time)
    

    Here is the commit: https://github.com/rails/rails/blob/4817bf94d135c44ddfae1a30acb15de989e3c86c/activesupport/lib/active_support/core_ext/time/conversions.rb

    I tested out monkey patching and it works like you would expect:

    ruby-1.9.2-p0 > class Time
    ruby-1.9.2-p0 ?>  def to_time
    ruby-1.9.2-p0 ?>    self
    ruby-1.9.2-p0 ?>  end
    ruby-1.9.2-p0 ?>end
     => nil 
    ruby-1.9.2-p0 > Time.zone = Time.zone_default = "UTC"
     => "UTC" 
    ruby-1.9.2-p0 > t = "2008-04-01".to_time
     => 2008-04-01 00:00:00 UTC 
    ruby-1.9.2-p0 >  p t.zone, t.to_time.zone
    "UTC"
    "UTC"
     => ["UTC", "UTC"] 
    

    I would consider this a bug

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this table (from http://www.tizag.com/mysqlTutorial/mysqlmax.php ): Id name type price 123451 Park's Great Hits
Consider this: public class TestClass { private String a; private String b; public TestClass()
Consider this trigger: ALTER TRIGGER myTrigger ON someTable AFTER INSERT AS BEGIN DELETE FROM
consider this string prison break: proof of innocence (2006) {abduction (#1.10)} i just want
Consider this class. public class DynamicField implements Comparable<DynamicField> { String title; int position; int
Consider this function getPos() which returns a tuple. What is the difference between the
Consider this query: WITH Scores (score) AS ( SELECT CAST(score AS INTEGER) FROM (
Consider this following code (that retrieves the response from a HTTP request and prints
Consider this problem: I have a program which should fetch (let's say) 100 records
Consider this code... using System.Threading; //... Timer someWork = new Timer( delegate(object state) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.