İçereği Atla
Menü
Bu soru işaretlendi
3997 Görünümler

Hi,

my goal is to display a datetime in the format hours:minutes in a tree view.

I first tried to format my datetime directly in the XML but without success.

Then, I decided to create a new field in my model :

heure_debut = fields.Char(string="Test"compute="_compute_jour")


I defined its value in the following function :

@api.depends('start_date')
    def _compute_jour(self):
        for meeting in self:
            if meeting.start:
                meeting.heure_debut = meeting.start.time().strftime("%H:%M")


The problem I have is that the string has a difference of one hour with the datetime

For example I have this :

Datetime                                    Test

22/02/2021 01:00:00                  00:00

22/02/2021 04:00:00                 03:00   


I think it comes from the timezone but I don't understand how I can include the timezone in the code to obtain the correct string. I could just add an hour to the datetime but I think I will have problems with the time change.


Thank you

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Tem 21
6099
3
Tem 25
3915
1
Şub 21
10038
6
Eyl 19
11190
2
Mar 16
7834