ionic-datepicker icon indicating copy to clipboard operation
ionic-datepicker copied to clipboard

Improvement: easier way to change months

Open rcluan opened this issue 9 years ago • 2 comments

Hello there, I've notice that changing the months is a bit annoying. You've got to select the month and then the year to get the correct date. To avoid this I did a nextDate() and previousDate(), so feel free to add it to the project. Worth saying I'm using moment.js to increment and decrement the month, but I think this can be easily changed.

this.nextDate = function() {

    var date = this.tempDate;
    var nextDate = moment(date).add(1, 'month');

    this.selectMonth(nextDate._d.getMonth());
    this.selectYear(nextDate._d.getFullYear());
}

this.previousDate = function() {

    var date = this.tempDate;
    var previousDate = moment(date).subtract(1, 'month');

    this.selectMonth(previousDate._d.getMonth());
    this.selectYear(previousDate._d.getFullYear());
}

I also changed the template in a way the Month and Year labels are between an arrow-left icon and an arrow-right icon:

`

{{datepickerCtrl.getTempMonth()}} {{datepickerCtrl.tempDate | date: 'yyyy'}}
`

rcluan avatar Jan 04 '16 18:01 rcluan

I'm thinking about create separate ways to select date, default one and one to your suggestion, and people may select the way they prefer.

What do you think about it?

Could you help with a PR allowing this selection?

Thanks.

celsomarques avatar Jan 08 '16 15:01 celsomarques

That's great. I think I kinda did this since I just added the arrows to change the months and kept your option of change as well. Good to have more than one way to use the datepicker. :D cheers On 8 Jan 2016 12:47, "celsomarques" [email protected] wrote:

I'm thinking about create separate ways to select date, default one and one to your suggestion, and people may select the way they prefer.

What do you think about it?

Could you help with a PR allowing this selection?

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/celsomarques/ionic-datepicker/issues/10#issuecomment-170036090 .

rcluan avatar Jan 08 '16 15:01 rcluan