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 · 3 comments
Open
10 tasks

Remove Moment.js dependency #815

wojciechczerniak opened this issue Oct 30, 2018 · 3 comments
Milestone

Comments

@wojciechczerniak
Copy link
Collaborator

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 commented Sep 12, 2019

Do we have any updates on this?

@Abhi0725
Copy link

The readme says that moment is optional still we get warning during the build for moment not found.

@artemkliaus
Copy link

This get warning...

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

No branches or pull requests

4 participants