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

Remove Moment.js dependency #815

Open
10 tasks
wojciechczerniak opened this issue Oct 30, 2018 · 1 comment
Open
10 tasks

Remove Moment.js dependency #815

wojciechczerniak opened this issue Oct 30, 2018 · 1 comment
Milestone

Comments

@wojciechczerniak
Copy link
Task lists! Give feedback
Collaborator

@wojciechczerniak wojciechczerniak commented Oct 30, 2018

Checklist

How to update from 1.x to 2.x

getMoment

Use getDate.

let momentDate = moment(pikadayInstance.getDate());

setMoment

Use setDate.

pikadayInstance.setDate(momentDate.toDate(), preventOnSelect);

toString

Define custom toString function in Pikaday options.

let pikaday = new Pikaday({
    ...
    toString(date, format) {
        return moment(date).format(format);
    },
});

parse

Define custom parse function in Pikaday options.

let pikaday = new Pikaday({
    ...
    parse(dateString, format) {
        let date = moment(dateString, format, formatStrict);
        return (date && date.isValid()) ? date.toDate() : null;
    },
});

formatStrict

See parse section above.

Advanced Moment integration example

You can use moment js to localize Pikaday!

moment.locale('nl');

var pikadayLocale = {
    previousMonth: 'Previous Month',
    nextMonth: 'Next Month',
    months: moment.months(),
    weekdays: moment.weekdays(),
    weekdaysShort: moment.weekdaysShort()
};

Source: #472 (comment)

@kazzkiq
Copy link

@kazzkiq kazzkiq commented Sep 12, 2019

Do we have any updates on this?

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

Successfully merging a pull request may close this issue.

None yet
2 participants