Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

uib-datepicker-popup : *Today* button does not count timezone #6147

Closed
cyberfish-dev opened this issue Aug 8, 2016 · 8 comments
Closed

uib-datepicker-popup : *Today* button does not count timezone #6147

cyberfish-dev opened this issue Aug 8, 2016 · 8 comments

Comments

@cyberfish-dev
Copy link

To reproduce :

  1. Set local timezone to +8:00
  2. Set timezone option of uib-datepicker-popup to be '-4:00'
  3. Set this date to ng-model option of datepicker-popup 'Mon Aug 08 2016 12:00:00 GMT+0800 (China Standard Time)'
  4. Datepicker shows Aug 07 as expected, and selects todays date as Aug 07 too in the popup. But when you click on Today button, it selects Aug 08 instead of Aug 07.
@wesleycho
Copy link
Contributor

Can you create a Plunker that demonstrates it? Here is a base you can work off of.

Also, did you configure ng-model-options for the datepicker-options as well as the popup?

@wesleycho
Copy link
Contributor

Ah, I see what is the issue here - you did not set the model to a date object, but a string. If you set the model to new Date('Mon Aug 08 2016 12:00:00 GMT+0800'), this should be fixed.

We do not support string models.

@cyberfish-dev
Copy link
Author

No, I provide Date object to model, I just wrote string representation to make it easier to understand, will write plunker for this and 6146 this evening

@cyberfish-dev
Copy link
Author

yeah, I saw that you must also provide ngModelOptions with timezone information to dateOptions, if not provided it just does not count the right todays date in the popup, I found it looking in bootstrap.js code though, could not find it in docs..

@cyberfish-dev
Copy link
Author

Here is the plunker
http://plnkr.co/edit/FztbDALRM3BsOFiPNgR2?p=preview

  1. please set your machine's date to be Mon Aug 08, 06:00 AM, with timezone GMT+0800
  2. open popup and click on Today button
  3. expect that today is Aug 07 in timezone '-04:00' because it must do Mon Aug 08, 06:00 AM minus 12 hours = Aug 07 18:00 , but todays date selects as Aug 08 instead.

@cyberfish-dev
Copy link
Author

Sorry, but I don't see that it was fixed, here is the updated plunker http://plnkr.co/edit/FztbDALRM3BsOFiPNgR2?p=preview

(I changed only bootstrap version there to //angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.0.2.js)

@cyberfish-dev
Copy link
Author

Still does not work for me, here is updated plunker. http://plnkr.co/edit/jKJY8X?p=preview

  1. Please set your local time to Aug 08, 06:00 AM , with timezone GMT+0800
  2. I expect that todays date of datepciker should be Aug 07 in -04:00 timezone
  3. Datepicker's input has date of Aug 07, but when I open popup, it shows Aug 06.
    http://prntscr.com/c8ttmc
  4. When I click Today button in datepicker-popup, I expect to see Aug 07, but input has Aug 08 and in popup it shows like Aug 07. http://prntscr.com/c8ttgl

@larionov
Copy link

Still doesn't work in 2.5.0
plunkr: https://plnkr.co/edit/XZKE07hEMbIUTSZJWhzr?p=preview

  1. set your local timezone to 'America/Los_Angeles', and time to Apr 25, 22:00
  2. open the plunkr, datepicker shows 26-April-2017 (expected 25-April-2017)
  3. open datepicker, press "Clear"
  4. open datepicker, press "Today", it shows 26-April-2017 (expected 25-April-2017)
  5. open datepicker, press "Today" again, it shows 25-April-2017 (expected, bu it should have been like that from the start)

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

Successfully merging a pull request may close this issue.

3 participants