Browse Source

Fix for default date.

pull/419/head
Sebastian Stehle 7 years ago
parent
commit
b617766cc8
  1. 2
      src/Squidex/app/shared/state/contents.forms.spec.ts
  2. 4
      src/Squidex/app/shared/state/contents.forms.ts

2
src/Squidex/app/shared/state/contents.forms.spec.ts

@ -272,7 +272,7 @@ describe('DateTimeField', () => {
it('should return calculated date when Today for DateFieldProperties', () => {
const field2 = createField({ properties: new DateTimeFieldPropertiesDto('DateTime', { calculatedDefaultValue: 'Today' }) });
expect(FieldDefaultValue.get(field2, now)).toEqual('2017-10-12');
expect(FieldDefaultValue.get(field2, now)).toEqual('2017-10-12T00:00:00Z');
});
it('should return calculated date when Now for DateFieldProperties', () => {

4
src/Squidex/app/shared/state/contents.forms.ts

@ -346,9 +346,9 @@ export class FieldDefaultValue implements FieldPropertiesVisitor<any> {
const now = this.now || DateTime.now();
if (properties.calculatedDefaultValue === 'Now') {
return now.toUTCStringFormat('YYYY-MM-DDTHH:mm:ss') + 'Z';
return `${now.toUTCStringFormat('YYYY-MM-DDTHH:mm:ss')}Z`;
} else if (properties.calculatedDefaultValue === 'Today') {
return now.toUTCStringFormat('YYYY-MM-DD');
return `${now.toUTCStringFormat('YYYY-MM-DD')}T00:00:00Z`;
} else {
return properties.defaultValue;
}

Loading…
Cancel
Save