Giter Club home page Giter Club logo

Comments (5)

joshuacronemeyer avatar joshuacronemeyer commented on July 3, 2024

Seems like you have a good handle on this. Can you create a PR?

from timecop.

joshuacronemeyer avatar joshuacronemeyer commented on July 3, 2024

Was thinking about this and wanted to see more test cases. Seems like the correct behavior is to keep the Date part and only change the time

3.0.1 :002 > Time.now
 => 2023-11-02 07:30:29.518102 -0700
3.0.1 :003 > DateTime.parse('06:00:00')
 => Thu, 02 Nov 2023 06:00:00 +0000
3.0.1 :004 > DateTime.parse('01:00:00')
 => Thu, 02 Nov 2023 01:00:00 +0000
3.0.1 :005 > DateTime.parse('15:00:00')
 => Thu, 02 Nov 2023 15:00:00 +0000

from timecop.

ilyakuzmin avatar ilyakuzmin commented on July 3, 2024

It depends on frozen time you use. Not sure what we can do with all this case in parse_with_mock_date, too much variations

case 1 correct

> Time.now
2022-08-02 09:50:00 +0300

> DateTime.parse("15:00:00")
Tue, 02 Aug 2022 15:00:00 +0000

> Timecop.top_stack_item
#<Timecop::TimeStackItem:... @travel_offset=-39521870.819318704

> 39521870.0 / 60 / 60 / 24
457.429050925926

> Timecop.top_stack_item.travel_offset_days
-457

case 2 incorrect

> Time.now
2022-08-02 05:50:00 +0300

> DateTime.parse("15:00:00")
Mon, 01 Aug 2022 15:00:00 +0000

> Timecop.top_stack_item
#<Timecop::TimeStackItem:... @travel_offset=-39536896.712171

> 39536896.0 / 60 / 60 / 24
457.602962962963

> Timecop.top_stack_item.travel_offset_days
-458

from timecop.

joshuacronemeyer avatar joshuacronemeyer commented on July 3, 2024

@ilyakuzmin does this fix it?

#415

from timecop.

joshuacronemeyer avatar joshuacronemeyer commented on July 3, 2024

I am going to merge that fix. Please reopen @ilyakuzmin if this issue is not fixed on main

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.