Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If you set the inputtime to 8:30 the control makes it 9:30 #86

Closed
dickverweij opened this issue Jun 9, 2016 · 8 comments
Closed

If you set the inputtime to 8:30 the control makes it 9:30 #86

dickverweij opened this issue Jun 9, 2016 · 8 comments

Comments

@dickverweij
Copy link

This is because you use toFixed(0) to round the value for the hours.
You need to use Math.floor..

image

@dickverweij dickverweij changed the title If you set the inputtime to 8:30 the controls makes it 9:30 If you set the inputtime to 8:30 the control makes it 9:30 Jun 9, 2016
@DharmendraVaishnav91
Copy link

+1 I am facing the same issue.

keinajar pushed a commit to keinajar/ionic-timepicker that referenced this issue Jun 15, 2016
rajeshwarpatlolla added a commit that referenced this issue Jun 26, 2016
@lucasdoamaral
Copy link

I need to write this junky piece of code, to fix this in runtime.

image

Even with the commit made by @KoiYu the problem continues to happen. Any news about that?

@keinajar
Copy link

keinajar commented Jul 5, 2016

@lucasdoamaral I don't understand your problem without more context.

If your currentTime represents inputTime option, then remember: inputTime is not a Date object.

If you wish to use Date objects (I do, at least), then you could use the following options:

$scope.data.created = new Date();

$scope.changeTime = function() {
            ionicTimePicker.openTimePicker({
                callback: function(val) {
                    var hours = Math.floor(val / 60 / 60),
                        minutes = val / 60 % 60;
                    $scope.data.created.setHours(hours, minutes);
                },
                inputTime: ((($scope.data.created.getHours() * 60 * 60) + (($scope.data.created.getMinutes() * 60)))),
                format: 24
            });
        };

@lync0056
Copy link

Hi @KoiYu ,

What they are saying is correct. I am experiencing the same issue. With your code, if I open, the current time in midday (12.03pm). The input on 12 hour clock time will show as 00 : 03 pm. I think before that I did it at 11.55am and it showed as 12.55am.

Very useful Directive. Thank you.

Cameron

@vikramaditya234
Copy link

+1 still the issue, please regenerate ionic-timepicker.bundle.min.js
this is the fix

@osirisr
Copy link

osirisr commented Aug 6, 2016

Had the same problem (toFixed was rounding the time). @KoiYu fix worked. Really wish I checked here first instead of spending 3 hours finding the bug myself.

@brunodeprez
Copy link

Hi,

could you push the new version of this component to bower, including your fix of this issue ?

Thanks

@rajeshwarpatlolla
Copy link
Owner

Fixed in v0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants