Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DatePart, DatePartInfo } from '../../directives/date-time-editor/date-time-editor.common';
import { formatDate, FormatWidth, getLocaleDateFormat } from '@angular/common';
import { formatDate } from '@angular/common';
import { ValidationErrors } from '@angular/forms';
import { isDate } from '../../core/utils';
import { getLocaleDateFormat, isDate } from '../../core/utils';
import { DataType } from '../../data-operations/data-util';

/** @hidden */
Expand Down Expand Up @@ -283,22 +283,7 @@ export abstract class DateTimeUtil {
* Supports Angular's DatePipe format options such as `shortDate`, `longDate`.
*/
public static getLocaleDateFormat(locale: string, displayFormat?: string): string {
Copy link
Member

@skrustev skrustev Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also a few methods using Intl.DateTimeFormat that can be replaced to use the new date formatters from igniteui-i18n-core. For example formatDate(should use the util.js format date instead), getDefaultInputFormat, getLocaleInputFormatFromParts and methods that use them maybe as well.

const formatKeys = Object.keys(FormatWidth) as (keyof FormatWidth)[];
const targetKey = formatKeys.find(k => k.toLowerCase() === displayFormat?.toLowerCase().replace('date', ''));
if (!targetKey) {
// if displayFormat is not shortDate, longDate, etc.
// or if it is not set by the user
return displayFormat;
}
let format: string;
try {
format = getLocaleDateFormat(locale, FormatWidth[targetKey]);
} catch {
DateTimeUtil.logMissingLocaleSettings(locale);
format = DateTimeUtil.getDefaultInputFormat(locale);
}

return format;
return getLocaleDateFormat(locale, displayFormat);
}

/** Determines if a given character is `d/M/y` or `h/m/s`. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
}

public get displayFormat(): string {
return this._displayFormat || this.inputFormat;
return this._displayFormat || this._inputFormat || DateTimeUtil.getLocaleDateFormat(this.locale, 'short');
}

/**
Expand Down