Skip to content

Commit d8cc8d2

Browse files
committed
feat(time-field,time-picker): separate components #25
1 parent dde81ee commit d8cc8d2

11 files changed

Lines changed: 696 additions & 578 deletions

File tree

src/tedi/components/form/time-field/components/time-grid/time-grid.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/tedi/components/form/time-field/components/time-wheel/time-wheel.tsx

Lines changed: 0 additions & 273 deletions
This file was deleted.

src/tedi/components/form/time-field/time-field-helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ export const findClosestMinute = (target: string, mins: string[]): string => {
4242
/**
4343
* Parses HH:mm time string
4444
*/
45-
export const parseTime = (time: string) => {
46-
const [h = '00', m = '00'] = (time ?? '00:00').split(':');
45+
export const parseTime = (time: string): { hour: string; minute: string } => {
46+
if (!time || !time.includes(':')) {
47+
return { hour: '00', minute: '00' };
48+
}
4749

50+
const [hour, minute] = time.split(':');
4851
return {
49-
hour: h.padStart(2, '0'),
50-
minute: m.padStart(2, '0'),
52+
hour: hour.padStart(2, '0'),
53+
minute: minute.padStart(2, '0'),
5154
};
5255
};
5356

0 commit comments

Comments
 (0)