Git Product home page Git Product logo

Comments (3)

mfogel avatar mfogel commented on June 2, 2024

thanks for the bug report @atleta

What would be super helpful if you have the time is to write up a failing test case and add it to https://github.com/mfogel/django-timezone-field/blob/master/tests/tests.py#L485-L575. Either as a PR or just a block of code on this ticket. If you don't have time I will get to this as soon as I can, but it'll be a few days at best

#71 is probably the same issue

from django-timezone-field.

atleta avatar atleta commented on June 2, 2024

@mfogel I've looked into the code on github and it turns out that you have already fixed it here:

delta = now_tz.replace(tzinfo=pytz.utc) - now

And this seems to fix the issue (I haven't tested it)

Interesting enough, when testing the bogus (4.1.1) version in the console with a trivial test case (see below) it gives the NonExistentTimeError. I.e. a different one than what I have seen when trying to run e.g. manage shell (or runserver). But the issue was the same.

with freeze_time('2021-03-28 01:44:14.162132'):
    TimeZoneField(default='UTC', choices_display='WITH_GMT_OFFSET')

or even

with freeze_time('2021-03-28 01:44:14.162132'):
     class M(models.Model):
        TimeZoneField(default='UTC', choices_display='WITH_GMT_OFFSET')

Anway, regarding your fix (see above): the replace and the substraction is unnecessary. You could simply use: delta = now_tz.utcoffset(). Which also means that you can probably merge it with the line above. It won't cause a problem due to what I have said above and it's more expressive.

from django-timezone-field.

mfogel avatar mfogel commented on June 2, 2024

Anway, regarding your fix (see above): the replace and the subtraction is unnecessary. You could simply use: delta = now_tz.utcoffset().

Please feel free to give it a go! Make sure the tests still pass, and if they do, then please file a pull request.

Sounds like this bug is a duplicate of #70 which affected v4.1.1 and was fixed in 37249c6 for v4.1.2. If that's not right and you are seeing this bug with version v4.1.2 then please reopen.

from django-timezone-field.

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.