콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
16385 화면

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
34570
4
1월 20
6388
2
11월 24
8171
3
8월 22
21407
0
2월 22
3834