Skip to content

DateField: getDisplayValue ignores specified format #467

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())));
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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