[dojo-contributors] How to construct Date object from string?

LiuCougar liucougar at gmail.com
Thu Jun 29 14:40:41 EDT 2006

On 6/29/06, Kun Xi <bookstack at gmail.com> wrote:
> Hi all,
> I checked the Ticket #1008, "dropdowndatepicker can't handle other
> date formats" in the trac, and find the problem is caused by
> DropdownDatePicker.js, Ln 47:
>                 onInputChange: function(){
> Ln:47           var tmp = new Date(this.inputNode.value);
>                         this.datePicker.date = tmp;
>                         this.datePicker.setDate(dojo.widget.DatePicker.util.toRfcDate(tmp));
>                         this.datePicker.initData();
>                         this.datePicker.initUI();
>                 }
> Here, the tmp is constructed from the input field regardless the input
> format, it is might be easier to fix this bug, if the following
> function is supported:
> var tmp = new Date( this.inputNode.value, this.dateFormat );
javascript 1.5/1.6 does not support this

> Any idea to construct a Date object based upon input and format ?
You need to parse the input string yourself and feed that to Data

"People's characters are strengthened through struggle against
difficulties; they are weakened by comfort."
- Old Chinese adage

More information about the dojo-contributors mailing list