IDE question: When manually editing a value in a datetime column, how do we edit the time zone?

I’m not in England, so when I set a time, manually, it needs to be in the proper timezone.

  1. I should be able to enable use of a local time zone, when needed, for entry and display.
  2. I should be able to adjust which time zone it is, e.g., as if I was entering data from a customer who’s not in my time zone.
1 Like

AFAIK you can’t change the time zone of a datetime column in a data table. What you would need to do is convert to UTC when adding date times to the data table.

(emphasis mine). I’m looking for a way to do it in the IDE’s calendar pop-up, not the database.

After all,

  1. the browser knows which time zone I’m in, so it could adjust for it.
  2. It should let me override that adjustment to accommodate my being in the wrong time zone.

Edit: I created a Feature Request entry: IDE Datetime column editor show local time zone

When you use the output of the calendar popup you should be able to use dt.replace(tzinfo=X) where X is a timezone from pytz.

Yes, if the popup was running on one of my own forms in my own app, I could pre- and post-process it any way I wanted.

However, I’m talking about the popup used by the IDE when you click on a datetime value in an IDE-displayed table. That is, this one:

The value entered here goes straight into the database. There is no opportunity for my code to “massage” the value, before other code sees it. See my Feature Request for some of the more likely human errors in trying to deal with time zones manually.

1 Like

Timezones are such a minefield… :exploding_head:

As an option could you include a text column for timezone

and use the pytz library

and then in the server function use

from pytz import timezone
import pytz
utc = pytz.utc

row = app_status_row
tzone = timezone(row['timezone'])
shutdown_no_tzone = row['planned_shutdown'].replace(tzinfo=None)
shutdown_local = tzone.localize(shutdown_no_tzone)
shutdown_utc = shutdown_local.as_timezone(utc)

http://pytz.sourceforge.net/

I’m going to try to change the title of this topic to better reflect the “IDE” aspect.

@stucork, I like this idea. To summarize the strategy (for more casual readers), this uses the additional column as an “override” of the datetime’s built-in timezone. In many cases it can be a more-than-adequate workaround, where an app has to read the datetime.

The main drawback comes when editing the data in the IDE. Now the timestamp is spread across two column values, and you can change only one of them at a time. If both have to change, then you have to hope that no program is going to try to read “the value” during the time that the two parts are out-of-sync.

I believe this was the reason why timezone information was embedded in the value in the first place: to make such changes atomic.

The logical way to represent the choice, of course, is as a pulldown list. (For usability, I’d put the most-frequently-used choices at the top.) The place, on-screen, to put this pulldown list, is directly underneath the datetime-entry-widget’s [Apply] and [Cancel] buttons.

Entry’s not an issue in my own apps. When needed, I can create a custom component that incorporates both datetime entry and an explicit timezone. But I can’t make the IDE use it.

Hi @p.colbert

Agreed, this is absolutely something you should be able to do in the IDE. Feature request duly noted :slight_smile: