GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Codemod to add `tz=UTC` to any `datetime` function without a timezone · Issue #385 · pixee/codemodder-python

Codemod to add tz=UTC to any datetime function without a timezone #385

New issue
Copy link
New issue
Copy link
Open
Open
Codemod to add tz=UTC to any datetime function without a timezone#385
Copy link
Labels
new-codemodDescription for a new codemodDescription for a new codemod

Description

@clavedeluna
clavedeluna
opened on Mar 18, 2024
Issue body actions

A while ago I discovered this flake8 datetime plugin which if installed warns you if you use something like datetime.datetime() (and others in the page). As is, the timezone used is whatever timezone the machine that runs the code is using. This may be okay in some cases, but it can lead to bugs. And misinterpretation of dates have been the culprit for serious issues in banking, satellites, Y2K fiasco, etc. So this is really important.

My suggestion for this codemod is to add a tz=UTC parameter to force code to run in UTC time. The big downside here is if the machine that ran the code previously was using a different timezone, crashes or bugs can happen on the first run. But the big advantage here is that it will force developers to think about which timezone they need.

Activity

  1. clavedeluna
    added
    new-codemodDescription for a new codemodDescription for a new codemod
    on Mar 18, 2024
  2. drdavella commented on Mar 19, 2024

    @drdavella
    drdavella
    on Mar 19, 2024
    Contributor
    More actions

    @clavedeluna this is an interesting idea. I wonder whether this overlaps at all with #368?

  3. clavedeluna
    self-assigned this
    on May 1, 2024
  4. clavedeluna commented on May 6, 2024

    @clavedeluna
    clavedeluna
    on May 6, 2024
    ContributorAuthor
    More actions

    Also add the sonar rule as a sonar codemo
    https://rules.sonarsource.com/python/RSPEC-6903/

  5. clavedeluna commented on May 6, 2024

    @clavedeluna
    clavedeluna
    on May 6, 2024
    ContributorAuthor
    More actions

    I made quite a bit of progress in this branch but due to other work needs I'm going to unassign this for now.

  6. clavedeluna
    removed their assignment
    on May 6, 2024
  7. clavedeluna commented on Aug 19, 2024

    @clavedeluna
    clavedeluna
    on Aug 19, 2024
    ContributorAuthor
    More actions

    After completing [https://github.com//pull/802]) we should add all remaining functions listed in the flake8 plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-codemodDescription for a new codemodDescription for a new codemod

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.