nehakadam / AnyPicker

jQuery Picker Library for Android, iOS & Windows Phone. eg Date Picker, Time Picker, DateTime Picker, Custom Select etc
https://nehakadam.github.io/AnyPicker/
MIT License
116 stars 37 forks source link

setMinimumDate not allow value older than 1990 #10

Closed kkarimak closed 8 years ago

kkarimak commented 8 years ago

Hi,

I am using this component to choose birthday. I cannot put minumum date value older than 1990.

I have tried with:

var minBirthDate = new Date(1920, 1, 1, 0, 0, 0, 0);

and

onInit: function(){ this.setMinimumDate(minBirthDate); }

but not working.

nehakadam commented 8 years ago

To set Minimum Value, you can simply use following code -

$("#ip-de").AnyPicker(
{
    mode: "datetime",
    dateTimeFormat: "yyyy-MM-dd",
    minValue: new Date(1920, 01, 19)
});

When minValue is specified in the settings, year values since minValue will be added in year picker component. Year component will have values (1920 - 2015, 2016, 2017 - 2041). Since maxValue is not specified, maximum value of year will be calculated based on default value of maxRows (current_year + maxRows/2)(So, 2041 = 2016 + 25).

Another solution with setMinimumDate function -

$("#ip-de").AnyPicker(
{
    mode: "datetime",
    dateTimeFormat: "yyyy-MM-dd",
    maxRows: 200,
    onInit: function()
    {
        this.setMinimumDate("1920-01-01");
    }
});

Picker components get initialize before onInit function so, by default 50 rows will be added in years component ( (current_year - 24), current_year, (current_year + 25) ).

Or you can simply set -

$("#ip-de").AnyPicker(
{
    mode: "datetime",
    dateTimeFormat: "yyyy-MM-dd",
    maxRows: 200
});

With this year component will contains values from 1915 to 2116.