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

Format "DD/MM/YYYY" issue on reopen #214

Open
tpetrone opened this issue Feb 1, 2019 · 1 comment
Open

Format "DD/MM/YYYY" issue on reopen #214

tpetrone opened this issue Feb 1, 2019 · 1 comment

Comments

@tpetrone
Copy link

tpetrone commented Feb 1, 2019

Behaviour:

  • Use "DD/MM/YYYY" as format
  • Select February, 6
  • Click to open date picker again
  • The pre-selected month is June (6)

Expected:

  • Use "DD/MM/YYYY" as format
  • Select February, 6
  • Click to open date picker again
  • The pre-selected month is February (2)
@tpetrone
Copy link
Author

I would like to share the workaround we are using. Please share your thoughts.

custom-paper-pikaday.js

import moment from 'moment';
import layout from 'ember-paper/templates/components/paper-input';
import PikadayInput from 'ember-paper-pikaday/components/paper-pikaday';

export default PikadayInput.extend({
  layout,

  // Override method of PikadayMixin from ember-pikaday
  setPikadayDate() {
    const format = this.get('format');
    const value = this.get('value');

    if (!value) {
      this.get('pikaday').setDate(value, true);
    } else {
      const date = this.get('useUTC')
        ? moment.utc(moment(value, format).format('YYYY-MM-DD')).toDate()
        : moment(value, format).toDate();

      this.get('pikaday').setDate(date, true);
    }
  },
});

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

1 participant