Skip to content

DateField: getDisplayValue ignores specified format #467

@ghost

Description

When a DateField is displayed for editing it is formated as described by the format parameter form for ex. yyyy-MM-dd HH:mm.
When the DateField is displayed readonly it is formated via the current locale for ex. d.m.yyyy HH:mm.

Expactation:
The format of the field is always the same for editing and readonly when a format is given using the format otherwise the locale.

A solution could be:

  import format from 'date-fns/format';
....
  getDisplayValue() {
    return this.isBlank()
      ? null
      : (this.get('format') ? format(new Date(this.getValue()), this.get('format')) : this._toLocaleString(new Date(this.getValue())));
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions