Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Conversion from float_time to float [Closed]

By
Sudhir Arya (SA)
on 11/20/13, 7:29 AM 1,614 views

The Question has been closed

by
Sudhir Arya (SA)
on 11/21/2013 02:53:40

As we all know that we can use float field for time with the help of widget="float_time".

Now, my question is that how this float_time value is calculated/converted into float value.

Ex:

I am giving value 00:10 in my form and when I look into the db it shows 0.16666667.

Thanks in advance.

2
Prajul P T
On 11/20/13, 8:28 AM

This is the code in js for displaying value in float_time format:

case 'float_time':
    var pattern = '%02d:%02d';
    if (value < 0) {
        value = Math.abs(value);
        pattern = '-' + pattern;
    }
    var hour = Math.floor(value);
    var min = Math.round((value % 1) * 60);
    if (min == 60){
        min = 0;
        hour = hour + 1;
    }
    return _.str.sprintf(pattern, hour, min);

So in your case, in db it is stored as 0.16666667. So the min will be var min = Math.round((0.16666667 % 1) * 60); which will be 10 when rounded...

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/20/13, 7:29 AM
Seen: 1614 times
Last updated: 1/16/16, 4:08 PM