Short way to assign date to ngbDatepicker
<p>I'm using reactive forms in my Angular 2 webapp and I'm having troubles assigning the date to ngbDatepicker (ngbootstrap 1 alpha 6). My object has a date object such as:</p>

<pre><code>var myObject = {date: new Date(1, 9, 2016)};
</code></pre>

<p>and in my reactive form, it is configured as follow:</p>

<pre><code>input.form-control(name='date', ngbDatepicker, #date="ngbDatepicker", placeholder='jj.mm.aaaa', formControlName='date', type="text")
</code></pre>

<p>and I patch the form like this:</p>

<pre><code>this.form.patchValue({myObject: myObject});
</code></pre>

<p>The problem is that <code>ngbDatepicker</code> take the date with the following structure:</p>

<pre><code>{day: DD, month: MM, year: YYYY}
</code></pre>

<p>I have found a workaround that does:</p>

<pre><code>this.form.controls.myObject.controls.date.valueChanges
        .map((value) =&gt; {
            if(value) {
                if (typeof value.getMonth === 'function') {
                    this.form.controls.myObject.patchValue({
                        date: {
                            day: value.getUTCDay(),
                            month: value.getUTCMonth(),
                            year: value.getUTCFullYear()
                        }
                    });
                }
            }
            return value;
        })
        .subscribe((value) =&gt; {

        });
</code></pre>

<p>And everything works as expected (the date gets updated whenever form gets patched) but it is way too verbose (18 lines of code) and my form has a dozen of dates!</p>

<p>So my question is can I achieve the same result with a much shorter solution?</p>