Giter Club home page Giter Club logo

Comments (4)

yaauie avatar yaauie commented on July 23, 2024

10.days does not actually produce a Fixnum as it appears to; instead it returns a ActiveSupport::Duration object that masquerades as a Fixnum. From Timecop's perspective, the argument appears to be a Fixnum, so it adds it to Time.now,as it would any other Fixnum; what actually happens is dependent on ActiveSupport's monkey-patching of the Time class, and how it handles durations in a smart-but-darkly-magic maner.

1.9.3 :001 > (10.days).class
 => Fixnum
1.9.3 :002 > # lies.
1.9.3 :003 > Marshal.dump( 10.days )
 => "\004\bo:\034ActiveSupport::Duration\a:\v@valuei\003\000/\r:\v@parts[\006[\a:\tdaysi\017"

from timecop.

travisjeffery avatar travisjeffery commented on July 23, 2024

@yaauie @levity's issue is independent from the AS support since that was pushed in the time since he made the issue.

from timecop.

yaauie avatar yaauie commented on July 23, 2024

The argument is caught here, well before we get to the new ActiveSupport support, because the argument masquerades as a Fixnum.

Since AS monkey-patches Time#+ to handle ActiveSupport::Duration as an argument, the behavior above is the expected behavior; his 10.days did span his local DST change (note he's not working in utc, merely displaying the result in utc), and the result reflects that.

from timecop.

levity avatar levity commented on July 23, 2024

Thanks for the explanation, @yaauie. So AS is intentionally advancing one less hour, so that the time in my local time zone will appear to be exactly 10 days ahead. It makes sense to me now.

from timecop.

Related Issues (20)

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.