# Angular Material renderers - A Bug and an Error

**URL:** <https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145>\
**Category:** General\
**Created:** [September 2, 2020, 7:54pm UTC](https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145 "2020-09-02T19:54:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [September 2, 2020, 7:54pm UTC](https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145/1 "2020-09-02T19:54:29Z")

</div>

Hello!

Using

- Angular 7 with jsonforms/core@2.3.0 / jsonforms/angular-material@2.3.0

- Angular 9 with jsonforms/core@2.4.0 / jsonforms/angular-material@2.4.0

Given a very simple data object and schemas

```auto
{ "today": "" }

{
  "type": "object",
  "properties": { "today": { "type": "string", "format": "date" } }
}

{
  "type": "VerticalLayout",
  "elements": [{ "type": "Control", "scope": "#/properties/today" }]
}

```

### Expectation 1 (Possibly a Bug - possibly me not finding the correct documentation)

- When I pick a date (for example 9/1/2020 (US format)) that the date displayed is 9/1/2020.

### Reality

- When I pick a date, the date that is displayed is the PRIOR day.

- I assume this is a locale issue, but I am not sure how to fix this.

### Expectation 2 (Error condition)

- When I remove the date from the input box that there are no errors

### Reality

- When I delete the date from the input box I get `Cannot read property ‘toISOString’ of null`

- This is because in the DateControlRenderer this line is not checking for a valid value in event.value:

- `getEventValue = (event: any) => event.value.toISOString().substr(0, 10);`

### Please advise on how to resolve these issues. I don’t currently see issues reported for these items on github, so if they are bugs I can open an issue.

Thanks so much!!

_[[original thread](https://spectrum.chat/jsonforms/general/angular-material-renderers-a-bug-and-an-error~452f2217-ab7b-49c1-82fb-13c44deab690) by Thad Peiffer]_

---

<div class="post-metadata">

**Author:** ![eneufeld](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/eneufeld/32/10_2.png) [@eneufeld](https://jsonforms.discourse.group/u/eneufeld)\
**Post date:** [September 2, 2020, 8:34pm UTC](https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145/2 "2020-09-02T20:34:19Z")

</div>

Hi @specantt ,  
so the date showing the previous date is definitely a bug and the reason is the conversion to the ISO date which is UTC. I assume you have a north american time zone. Could you please open an issue for this?  
If you remove the date there will be no error if you use your schema. The reason is that the date is not required. So if you use a schema like this:

```auto
{
  "type": "object",
  "properties": { "today": { "type": "string", "format": "date" } },
  "required": ["today"]
}

```

you should have a validation error.  
Nonetheless there should be a null check before the `toIsoString()` call. Could you please open a separate issue for this, too?  
Thank you very much.  
We are also happy to accept contributions 😉 .

---

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [September 3, 2020, 2:11pm UTC](https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145/3 "2020-09-03T14:11:38Z")

</div>

_[Thad Peiffer]_

Thank you, @eneufeld(eneufeld) !

You are correct - I’m in North America. I though perhaps there was a configuration where I could set offset from UTC.

Also, in my case the date wasn’t a required field, so I wasn’t worried about not getting a validation error. I was only concerned about the exception being thrown in the JavaScript.

I’ll file bug reports. Would love to contribute - have done so before on open source projects. In reality, though, not sure if I can due to deadlines. I’m sure you know how that is! ☹

---

<div class="post-metadata">

**Author:** ![madla](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@madla](https://jsonforms.discourse.group/u/madla)\
**Post date:** [July 30, 2023, 12:40am UTC](https://jsonforms.discourse.group/t/angular-material-renderers-a-bug-and-an-error/145/4 "2023-07-30T00:40:52Z")

</div>

I see the same date being off due to time zone problem in the current version of the Angular JSONForm Seed project. I’m in North America as the originia poster. Anybody know how to handle this correctly?
