Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-18879

Modernize CQLSH datetime conversions

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 5.1-alpha1, 5.1
    • CQL/Interpreter
    • None
    • Code Clarity
    • Low Hanging Fruit
    • All
    • None
    • Hide

      Tested it manually.

      My timezone is US/Eastern. You can see the tracing output showing the time (2024-01-16 16:18:43.599000-05:00) in my timezone and the table containing the time in UTC (2024-01-16 21:18:43.599000+0000).

      (See attached log file)

      Show
      Tested it manually. My timezone is US/Eastern. You can see the tracing output showing the time ( 2024-01-16 16:18:43.599000-05:00 ) in my timezone and the table containing the time in UTC ( 2024-01-16 21:18:43.599000+0000 ). (See attached log file )

    Description

      Python 3.x introduced many updates to datetime conversion which allows simplified conversions.

      1. For example, tracing.py defines a function datetime_from_utc_to_local() but datetime now has a native function astimezone() which will convert UTC to local time.

      Review the following users of datetime which apply conversions:

      • cqlshmain.py
      • formatting.py 
      • tracing.py

      Example: 

      >>> from dateutil import tz
      >>> import datetime
      >>> a = datetime.datetime.now().astimezone(tz.tzutc())
      >>> a
      datetime.datetime(2023, 9, 25, 11, 22, 36, 251705, tzinfo=tzutc())
      >>> b = a.astimezone()
      >>> b
      datetime.datetime(2023, 9, 25, 14, 22, 36, 251705, tzinfo=datetime.timezone(datetime.timedelta(seconds=10800), 'EST')) 

      See [PEP 495]

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            arkn98 Arun Ganesh Assign to me
            bschoeni Brad Schoening
            Arun Ganesh
            Brad Schoening, Brandon Williams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 2h 20m
              2h 20m

              Slack

                Issue deployment