跳至内容
菜单
此问题已终结
1 回复
16007 查看

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
10月 24
34219
4
1月 20
6154
2
11月 24
7881
3
8月 22
21043
0
2月 22
3661