When a datetime is set using an initial value, any time unit (year, month, hour) not used in the template is lost, and when the resulting datetime is retrieved using getValue, it will be missing any units of the datetime not used in the template. This is because the datetime's value is stored and retrieved by accessing the dropdown element's values.
This restricts any format string units to the subset of specified template string units. I am unable to use years in my format string if my template string doesn't display years.
iso_string = 'YYYY-MM-DDTHH:MM:SS-Z';
$('#some_input).combodate({
template: 'S',
format: iso_string,
value: moment()
});
// Somebody changes the template drop down value
var missing_everything_but_seconds = $('#some_input').combodate('getValue', iso_string);
A change event could update an internally stored moment, and then the dropdowns could be set to the new value of the internally stored datetime.
Alternatively, hidden elements could be created to store values not used in the template string.
I am willing to help with a pull request if you are interested.
Thank you for your software!
When a datetime is set using an initial value, any time unit (year, month, hour) not used in the template is lost, and when the resulting datetime is retrieved using getValue, it will be missing any units of the datetime not used in the template. This is because the datetime's value is stored and retrieved by accessing the dropdown element's values.
This restricts any format string units to the subset of specified template string units. I am unable to use years in my format string if my template string doesn't display years.
A change event could update an internally stored moment, and then the dropdowns could be set to the new value of the internally stored datetime.
Alternatively, hidden elements could be created to store values not used in the template string.
I am willing to help with a pull request if you are interested.