Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3735 Prikazi

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
Opusti
Related Posts Odgovori Prikazi Aktivnost
3
jul. 21
5780
3
jan. 25
3427
1
feb. 21
9568
6
sep. 19
10658
2
mar. 16
7470