Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
16116 Visualizzazioni

Suppose if we have 13 hours and 02 minutes then the float value should be around 13.04 so when inserted into float field with float widget

1. 13:02

2. 19: 31

3. 14:40

some example to test...i need to get float value so that it works fine with float widget

Please give me some suggestions or solutions...Thanks in advance

Avatar
Abbandona
Risposta migliore

Hi,

Suppose if you have 13:05 as a string and if you need to convert it to float time use the below code,

def conv_time_float(self, value):
vals = value.split(':')
t, hours = divmod(float(vals[0]), 24)
t, minutes = divmod(float(vals[1]), 60)
minutes = minutes / 60.0
return hours + minutes


Thanks

Avatar
Abbandona
Autore

Its working fine thanks you so much

https://www.linkedin.com/in/dhananjay-patil895/

can you add me in your connection?

Post correlati Risposte Visualizzazioni Attività
3
ott 24
34296
4
gen 20
6230
2
nov 24
7948
3
ago 22
21131
0
feb 22
3721