Skip to content

Commit 60b5a30

Browse files
author
amandaesmith3
committed
get parseDate working with arrays
1 parent acb143f commit 60b5a30

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

core/src/components/datetime/datetime.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ export class Datetime implements ComponentInterface {
15321532
class="day-column"
15331533
color={this.color}
15341534
items={days}
1535-
value={workingParts.day || this.todayParts.day}
1535+
value={'' + (workingParts.day || this.todayParts.day)}
15361536
onIonChange={(ev: CustomEvent) => {
15371537
// Due to a Safari 14 issue we need to destroy
15381538
// the intersection observer before we update state

core/src/components/datetime/utils/parse.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ export const getPartsFromCalendarDay = (el: HTMLElement): DatetimeParts => {
5555
* We do not use the JS Date object here because
5656
* it adjusts the date for the current timezone.
5757
*/
58-
export const parseDate = (val: string | string[] | undefined | null): any | undefined => {
59-
// TODO
58+
export function parseDate(val: string): DatetimeParts;
59+
export function parseDate(val: string[]): DatetimeParts[];
60+
export function parseDate(val: undefined | null): undefined;
61+
export function parseDate(val: string | string[] | undefined | null): DatetimeParts | DatetimeParts[] | undefined;
62+
export function parseDate(val: string | string[] | undefined | null): DatetimeParts | DatetimeParts[] | undefined {
6063
if(Array.isArray(val)) {
61-
console.log("parseDate not implemented yet for arrays");
62-
return;
64+
return val.map(valStr => parseDate(valStr));
6365
}
6466

6567
// manually parse IS0 cuz Date.parse cannot be trusted
@@ -103,14 +105,13 @@ export const parseDate = (val: string | string[] | undefined | null): any | unde
103105
}
104106
}
105107

108+
// can also get second and millisecond from parse[6] and parse[7] if needed
106109
return {
107110
year: parse[1],
108111
month: parse[2],
109112
day: parse[3],
110113
hour: parse[4],
111114
minute: parse[5],
112-
second: parse[6],
113-
millisecond: parse[7],
114115
tzOffset,
115116
};
116117
};

0 commit comments

Comments
 (0)