Skip to content

Commit c134af7

Browse files
committed
fix: Parse non ISO based date formats for attrbiutes
Closes #1587
1 parent 0808554 commit c134af7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
- Parse non ISO based date formats when binding to a date attribute in components [#1587](https://github.com/IgniteUI/igniteui-webcomponents/issues/1587)
11+
712
## [5.3.0] - 2025-03-13
813
### Added
914
- Tile manager component [#1402](https://github.com/IgniteUI/igniteui-webcomponents/pull/1402)

src/components/calendar/calendar.interaction.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ describe('Calendar interactions', () => {
4444

4545
calendar.setAttribute('value', date.native.toISOString());
4646
expect(date.equalTo(calendar.value!)).to.be.true;
47+
48+
// Non-ISO date string
49+
calendar.setAttribute('value', date.native.toString());
50+
expect(date.equalTo(calendar.value!)).to.be.true;
4751
});
4852

4953
it('setting `value` - string property binding', async () => {
@@ -52,6 +56,10 @@ describe('Calendar interactions', () => {
5256

5357
expect(date.equalTo(calendar.value!)).to.be.true;
5458

59+
// Non-ISO date string
60+
calendar.value = date.native.toString();
61+
expect(date.equalTo(calendar.value!)).to.be.true;
62+
5563
// Invalid date
5664
for (const each of [new Date('s'), '', null, undefined]) {
5765
calendar.value = each;
@@ -72,6 +80,16 @@ describe('Calendar interactions', () => {
7280
expect(calendar.values).lengthOf(2);
7381
expect(date_1.equalTo(first(calendar.values))).to.be.true;
7482
expect(date_2.equalTo(last(calendar.values))).to.be.true;
83+
84+
// Non-ISO date format
85+
calendar.setAttribute(
86+
'values',
87+
`${date_1.native.toString()}, ${date_2.native.toString()}`
88+
);
89+
90+
expect(calendar.values).lengthOf(2);
91+
expect(date_1.equalTo(first(calendar.values))).to.be.true;
92+
expect(date_2.equalTo(last(calendar.values))).to.be.true;
7593
});
7694

7795
it('setting `values` - string property binding', async () => {
@@ -88,6 +106,13 @@ describe('Calendar interactions', () => {
88106
expect(date_1.equalTo(first(calendar.values))).to.be.true;
89107
expect(date_2.equalTo(last(calendar.values))).to.be.true;
90108

109+
// Non-ISO date formats
110+
calendar.values = `${date_1.toString()}, ${date_2.toString()}`;
111+
112+
expect(calendar.values).lengthOf(2);
113+
expect(date_1.equalTo(first(calendar.values))).to.be.true;
114+
expect(date_2.equalTo(last(calendar.values))).to.be.true;
115+
91116
// Valid date combinations
92117
const validDates = [
93118
[date_1_str, date_2_str],

src/components/calendar/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function parseISODate(string: string) {
5252
return isValidDate(new Date(`${date}T${string}`));
5353
}
5454

55-
return null;
55+
return isValidDate(new Date(Date.parse(string)));
5656
}
5757

5858
/**

0 commit comments

Comments
 (0)