Giter Club home page Giter Club logo

Comments (8)

ramaboo avatar ramaboo commented on August 16, 2024 1

Even the examples in the readme regarding timezone don't work!! :(

from stamp.

jeremyw avatar jeremyw commented on August 16, 2024

@ramaboo Can you add a failing test on a branch that reproduces the issue?

from stamp.

ramaboo avatar ramaboo commented on August 16, 2024

I don't know Minitest (Rspec here). The test is simple though in rails console type:

time = Time.utc(2011, 6, 9, 20, 52, 30)
time.stamp("23:59 UTC")             #=> "20:52 PST"

And you will see it's broken.

from stamp.

jeremyw avatar jeremyw commented on August 16, 2024

Here's what I just got:

irb(main):002:0> time = Time.utc(2011,6,9,20,52,30)
=> 2011-06-09 20:52:30 UTC
irb(main):003:0> time.stamp("23:59 UTC")
=> "20:52 UTC"

I wonder if something is modifying the behavior of the Time class. Are you
in a Rails app? What version of Ruby/Rails?

On Mon, May 23, 2016 at 6:55 PM, David Singer [email protected]
wrote:

I don't know Minitest (Rspec here). The test is simple though in rails
console type:

time = Time.utc(2011, 6, 9, 20, 52, 30)
time.stamp("23:59 UTC") #=> "20:52 PST"

And you will see it's broken.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#29 (comment)

from stamp.

ramaboo avatar ramaboo commented on August 16, 2024

Yeah Rails 4.2.6. I get the same thing as you but in your documentation you state the result should be "20:52 PST" not "20:52 UTC" I can't find a way to get `time.stamp('23:59 UTC') to return a string without UTC in it. No matter what I do it never turns UTC to PST or EST, etc.

from stamp.

jeremyw avatar jeremyw commented on August 16, 2024

That looks like a bad example in the documentation. However, I'm not sure convinced time zones are working correctly. I would expect stamp to emit the zone of the time object you're operating on, but that's not happening. It's been a while since I've been in that code, but it appears to use ENV['TZ'] to determine the current zone, not based on the zone of the time object.

I don't have a ton of time to investigate further right now, but please let me know if you discover anything or come up with a fix.

from stamp.

kbrock avatar kbrock commented on August 16, 2024
require 'active_support/all'
Time.current.stamp("UTC")
# => "EDT"  
Time.current.in_time_zone('MST').stamp("UTC")
# => "UTC"

looks like it probably thinks TimeWithZone is a Date and not a time.
will look into it

from stamp.

kbrock avatar kbrock commented on August 16, 2024

also of interest

DateTime.now.stamp("UTC")
# => "-04:00"  

require "active_support/time"
ActiveSupport::TimeWithZone.send(:include, ::Stamp)
Time.current.in_time_zone('MST').stamp("UTC")
# => "MST"

the method is not defined in TimeWithZone (as we know) and it tries to create a Time object but
ruby/2.2.2/gems/tzinfo-1.2.2/lib/tzinfo/timezone_period.rb:145 seems to be loosing the timezone. and the wrap with timezone is not able to get it back in time.

from stamp.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.