تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
16040 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

Its working fine thanks you so much

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

can you add me in your connection?

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أكتوبر 24
34228
4
يناير 20
6169
2
نوفمبر 24
7893
3
أغسطس 22
21056
0
فبراير 22
3681