Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
bf86e07
feat(time-input): add utils for toggling select and formatparts
shaneeza Nov 26, 2025
612b474
wip
shaneeza Nov 30, 2025
a578ecb
refactor(time-input): enhance time formatting utilities and improve d…
shaneeza Dec 1, 2025
804cd88
refactor(time-input): improve time input handling and formatting logic
shaneeza Dec 1, 2025
1db42af
feat(time-input): add TimeFormField and TimeFormFieldInputContainer c…
shaneeza Dec 1, 2025
206e145
temp remove ts check
shaneeza Dec 1, 2025
bb3916d
refactor(time-input): clean up unused select unit logic and improve s…
shaneeza Dec 1, 2025
df69d22
feat(time-input): enhance TimeInput component with new constants for …
shaneeza Dec 2, 2025
2f5707f
refactor(time-input): update time segment rules and default values to…
shaneeza Dec 2, 2025
9715407
refactor(time-input): simplify getFormatParts function by removing lo…
shaneeza Dec 2, 2025
dad7b62
test(time-input): add unit tests for getFormatParts utility to verify…
shaneeza Dec 2, 2025
f559593
refactor(time-input): remove locale dependency from formatParts in Ti…
shaneeza Dec 2, 2025
3e6f6be
feat(time-input): add default time parts and enhance time input conte…
shaneeza Dec 3, 2025
1ef4c97
merge conflits
shaneeza Dec 3, 2025
87023fb
feat(time-input): enhance TimeInput stories with new argTypes for dar…
shaneeza Dec 3, 2025
580c90f
test(time-input): add comprehensive unit tests for TimeInputSegment c…
shaneeza Dec 3, 2025
2495aa1
test(time-input): add comprehensive unit tests for TimeInputSegment c…
shaneeza Dec 3, 2025
4cad730
refactor(time-input): update time segment handling to use explicit is…
shaneeza Dec 3, 2025
1afe57e
refactor(time-input): rename shouldShowSelect to is12hFormat for clar…
shaneeza Dec 12, 2025
cb84996
refactor(time-input): clean up unused state and comments in TimeInput…
shaneeza Dec 12, 2025
6e265a7
chore(pnpm-lock): add workspace links for @leafygreen-ui/input-box to…
shaneeza Dec 12, 2025
2547fdc
refactor(time-input): remove unused console logs and simplify time fo…
shaneeza Dec 12, 2025
10d4039
merge conflict
shaneeza Dec 12, 2025
e46a73c
refactor(time-input): clean up comments and improve test descriptions…
shaneeza Dec 12, 2025
94ed98f
refactor(time-input): remove outdated TODO comment in TimeInputContex…
shaneeza Dec 12, 2025
7e42f34
merge conflict
shaneeza Dec 12, 2025
2d2fbd5
Merge branch 'shaneeza/segment-logic-integration' of github.com:mongo…
shaneeza Dec 12, 2025
d9b99ec
Merge branch 'LG-5538/segments-parse-time' of github.com:mongodb/leaf…
shaneeza Dec 12, 2025
f07a1b8
merge conflict
shaneeza Dec 12, 2025
ed87ee7
test(time-input): add unit tests for TimeInputBox component
shaneeza Dec 14, 2025
e18c444
feat(time-input): integrate LGIDs into TimeInput components for impro…
shaneeza Dec 14, 2025
a361ba7
test(time-input): add test to verify seconds input is not rendered wh…
shaneeza Dec 14, 2025
87fa353
feat(date-utils): add newUTCFromTimeZone function to create UTC dates…
shaneeza Dec 14, 2025
bf0c1a9
fix(time-input): update minExplicitValue for hour segment to ensure c…
shaneeza Dec 15, 2025
fdcbd44
fix(time-input): correct typos in test descriptions for segment valid…
shaneeza Dec 15, 2025
aa4e7a2
feat(time-input): implement getNonLiteralTimeParts utility function w…
shaneeza Dec 16, 2025
d38ee94
refactor(time-input): rename defaultTimeParts to defaultDateTimeParts…
shaneeza Dec 16, 2025
d57c109
refactor(time-input): simplify import structure for getFormatPartsVal…
shaneeza Dec 16, 2025
aff3376
refactor(time-input): enhance getFormatter utility to conditionally i…
shaneeza Dec 16, 2025
9e343ff
refactor(time-input): consolidate imports for utility functions in Ti…
shaneeza Dec 16, 2025
346cb74
feat(time-input): add getFormattedDateTimeParts utility with tests fo…
shaneeza Dec 19, 2025
31dba0b
refactor(time-input): rename TimeParts to DateTimeParts and update re…
shaneeza Dec 19, 2025
388339e
refactor(time-input): update documentation in getFormattedDateTimePar…
shaneeza Dec 19, 2025
cea6a1d
merge conflict
shaneeza Dec 19, 2025
8abc708
refactor(time-input): remove unused state and error message from Time…
shaneeza Dec 19, 2025
4458f6f
refactor(time-input): update styles for seamless input display and cl…
shaneeza Dec 19, 2025
5455489
Merge branch 'shaneeza/segment-logic-integration' of github.com:mongo…
shaneeza Dec 19, 2025
237c4ee
chore(version): update version to 5.2.0
shaneeza Dec 19, 2025
617ebb7
Merge branch 'LG-5538/segments-parse-time' of github.com:mongodb/leaf…
shaneeza Dec 19, 2025
cc26d00
merge conflict
shaneeza Dec 19, 2025
a736467
merge conflict
shaneeza Dec 19, 2025
c9751da
fix(time-input): update minExplicitValue for hour segment to ensure c…
shaneeza Dec 19, 2025
438f8ea
Merge branch 'LG-5532/segments-display-values' of github.com:mongodb/…
shaneeza Dec 19, 2025
819fbdf
feat(time-input): add utility functions for padded time segments and …
shaneeza Dec 19, 2025
cfcca09
feat(time-input): introduce DayPeriod type and update related utiliti…
shaneeza Dec 19, 2025
36e9fd9
feat(date-utils): add isSameUTCDayAndTime utility and corresponding t…
shaneeza Dec 19, 2025
97e751b
feat(date-utils): export isSameUTCDayAndTime utility and remove it fr…
shaneeza Dec 19, 2025
01c6487
fix(time-input): correct import structure for getPaddedTimeSegmentsFr…
shaneeza Dec 19, 2025
3730806
refactor(time-input): update tests for shouldSetValue utility to impr…
shaneeza Dec 19, 2025
f3d3102
refactor(date-utils): streamline imports in isSameUTCDayAndTime utili…
shaneeza Dec 20, 2025
7ccb116
feat(time-input): enhance time input context and segment change event…
shaneeza Dec 20, 2025
2b4acae
refactor(time-input): remove unused TimeInputDisplayContext utility file
shaneeza Dec 20, 2025
574a23a
refactor(time-input): streamline imports and enhance context utility …
shaneeza Dec 20, 2025
96b9ebd
feat(time-input): add TimeInputDisplayContext utility functions and d…
shaneeza Dec 20, 2025
e032c8b
refactor(time-input): update imports to use TimeInputDisplayContext u…
shaneeza Dec 20, 2025
26fec0b
merge conflict
shaneeza Dec 20, 2025
20d0b0e
refactor(time-input): update component props to use ComponentPropsWit…
shaneeza Dec 22, 2025
ba1dcd9
refactor(time-input): reorganize imports and move utility functions t…
shaneeza Dec 22, 2025
a04fca7
refactor(time-input): update component props to use ComponentPropsWit…
shaneeza Dec 22, 2025
379f871
refactor(time-input): move time segment rules and default min/max fun…
shaneeza Dec 22, 2025
ee79838
merge conflict
shaneeza Dec 22, 2025
80a5367
refactor(time-input): simplify aria attributes in TimeFormFieldInputC…
shaneeza Dec 22, 2025
4a62b19
refactor(time-input): simplify aria attributes in TimeFormFieldInputC…
shaneeza Dec 22, 2025
7ba3bab
Merge branch 'LG-5532/segments-display-values' of github.com:mongodb/…
shaneeza Dec 22, 2025
b7d5c15
refactor(date-utils): remove deprecated newUTCFromTimeZone function a…
shaneeza Dec 22, 2025
4c14124
fix(date-utils): update test descriptions for clarity on UTC offsets …
shaneeza Dec 22, 2025
522a987
refactor(date-utils): simplify test comments for better readability a…
shaneeza Dec 22, 2025
7d3d139
refactor(time-input): replace deprecated newUTCFromTimeZone with newT…
shaneeza Dec 22, 2025
e88a937
refactor(time-input): remove unused TimeInputSegmentChangeEvent type …
shaneeza Dec 22, 2025
a714dc8
refactor(time-input): rename defaultPlaceholder to defaultPlaceholder…
shaneeza Dec 22, 2025
9e0dd01
Merge branch 'LG-5532/segments-display-values' of github.com:mongodb/…
shaneeza Dec 22, 2025
2993da5
refactor(time-input): remove unused import of keyMap in shared types …
shaneeza Dec 22, 2025
bf03d5f
merge conflict
shaneeza Dec 23, 2025
644288d
testing
shaneeza Dec 23, 2025
d818cba
revert
shaneeza Dec 23, 2025
be44130
refactor(time-input): simplify isEverySegmentFilled utility and clean…
shaneeza Dec 23, 2025
451b0ea
refactor(time-input): enhance validation utilities by simplifying seg…
shaneeza Dec 23, 2025
2a4ffd3
refactor(time-input): rename isExplicitSegmentValue to createExplicit…
shaneeza Dec 23, 2025
10fb946
refactor(time-input): improve test descriptions in isEverySegmentValu…
shaneeza Dec 23, 2025
b0726e0
refactor(time-input): simplify doesSomeSegmentExist utility and enhan…
shaneeza Dec 23, 2025
06ee1ef
refactor(time-input): update DateTimeParts type to include dayPeriod …
shaneeza Dec 29, 2025
b11b0ec
refactor(time-input): introduce DateParts type for better date segmen…
shaneeza Dec 29, 2025
055f87c
refactor(date-utils): streamline test cases in isSameUTCDayAndTime.sp…
shaneeza Dec 29, 2025
dd11802
refactor(date-utils): enhance test clarity in isSameUTCDay.spec by im…
shaneeza Dec 29, 2025
85e285e
refactor(date-utils): improve test consistency in isSameUTCMonth.spec…
shaneeza Dec 29, 2025
3399988
refactor(time-input): enhance test descriptions and structure for cla…
shaneeza Dec 29, 2025
18e30a2
refactor(date-utils): improve test descriptions in isSameUTCDay.spec …
shaneeza Dec 29, 2025
5682f66
refactor(date-utils): rename isSameUTCDayAndTime to isSameUTCDateTime
shaneeza Dec 29, 2025
17210c4
refactor(date-utils): update exports and tests for isSameUTCDateTime
shaneeza Dec 29, 2025
4ab1e7d
refactor(time-input): consolidate unit option types and improve usage…
shaneeza Dec 30, 2025
58fcac0
refactor(time-input): enhance time and date segment handling by conso…
shaneeza Dec 30, 2025
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
1 change: 1 addition & 0 deletions packages/date-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export { isOnOrAfter } from './isOnOrAfter';
export { isOnOrBefore } from './isOnOrBefore';
export { isSameTZDay } from './isSameTZDay';
export { isSameTZMonth } from './isSameTZMonth';
export { isSameUTCDateTime } from './isSameUTCDateTime';
export { isSameUTCDay } from './isSameUTCDay';
export { isSameUTCMonth } from './isSameUTCMonth';
export { isSameUTCRange } from './isSameUTCRange';
Expand Down
1 change: 1 addition & 0 deletions packages/date-utils/src/isSameUTCDateTime/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { isSameUTCDateTime } from './isSameUTCDateTime';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { isSameUTCDateTime } from './isSameUTCDateTime';

describe('packages/time-input/utils/isSameUTCDateTime', () => {
test('returns true if the two dates are the same day and time in UTC', () => {
const date1 = new Date('2025-01-01T12:00:00Z');
const date2 = new Date('2025-01-01T12:00:00Z');
expect(isSameUTCDateTime(date1, date2)).toBe(true);
});

test('returns false if the two dates are not the same day in UTC', () => {
const date1 = new Date('2025-01-01T12:00:00Z');
const date2 = new Date('2025-01-02T12:00:00Z');
expect(isSameUTCDateTime(date1, date2)).toBe(false);
});

test('returns false if the two dates are not the same time in UTC', () => {
const date1 = new Date('2025-01-01T12:00:00Z');
const date2 = new Date('2025-01-01T12:00:01Z');
expect(isSameUTCDateTime(date1, date2)).toBe(false);
});

test('returns false if the two dates are not the same date and time in UTC', () => {
const date1 = new Date('2025-02-01T12:00:00Z');
const date2 = new Date('2025-01-01T12:00:01Z');
expect(isSameUTCDateTime(date1, date2)).toBe(false);
});

test('returns false when one or both dates is null', () => {
expect(isSameUTCDateTime(new Date(), null)).toBe(false);
expect(isSameUTCDateTime(null, new Date())).toBe(false);
expect(isSameUTCDateTime(null, null)).toBe(false);
});

test('returns false when one or both dates is invalid', () => {
expect(isSameUTCDateTime(new Date(), new Date('invalid'))).toBe(false);
expect(isSameUTCDateTime(new Date('invalid'), new Date())).toBe(false);
expect(isSameUTCDateTime(new Date('invalid'), new Date('invalid'))).toBe(
false,
);
});
});
25 changes: 25 additions & 0 deletions packages/date-utils/src/isSameUTCDateTime/isSameUTCDateTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { isValidDate } from '../isValidDate';
import { DateType } from '../types';

/**
* Checks if two dates are the same date and time in UTC.
*
* @param day1 - The first date to check
* @param day2 - The second date to check
* @returns Whether the two dates are the same date and time in UTC
*/
export const isSameUTCDateTime = (
day1?: DateType,
day2?: DateType,
): boolean => {
if (!isValidDate(day1) || !isValidDate(day2)) return false;

return (
day1.getUTCDate() === day2.getUTCDate() &&
day1.getUTCMonth() === day2.getUTCMonth() &&
day1.getUTCFullYear() === day2.getUTCFullYear() &&
day1.getUTCHours() === day2.getUTCHours() &&
day1.getUTCMinutes() === day2.getUTCMinutes() &&
day1.getUTCSeconds() === day2.getUTCSeconds()
);
};
88 changes: 70 additions & 18 deletions packages/date-utils/src/isSameUTCDay/isSameUTCDay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,109 @@ import { mockTimeZone } from '../testing/mockTimeZone';

import { isSameUTCDay } from '.';

const TZOffset = -5;
const americaNewYorkTimeZone = 'America/New_York';

describe('packages/date-utils/isSameUTCDay', () => {
beforeEach(() => {
mockTimeZone('America/New_York', -5);
mockTimeZone(americaNewYorkTimeZone, -4); // EDT is UTC-4 (4 hours behind UTC) in September
});
afterEach(() => {
jest.resetAllMocks();
});

describe('when both dates are defined in UTC', () => {
test('returns true', () => {
test('returns true when both dates are equal', () => {
const utc1 = newUTC(2023, 8, 1, 0, 0, 0);
const utc2 = newUTC(2023, 8, 1, 21, 0, 0);
expect(isSameUTCDay(utc1, utc2)).toBe(true);
});

test('returns false', () => {
test('returns false when both dates are not equal', () => {
const utc1 = newUTC(2023, 8, 1, 0, 0, 0);
const utc2 = newUTC(2023, 8, 2, 0, 0, 0);
expect(isSameUTCDay(utc1, utc2)).toBe(false);
});
});

describe('when one date is defined locally', () => {
test('returns true ', () => {
const utc = newUTC(2023, 8, 10, 0, 0, 0);
// '2023-09-09T21:00:00' NY time
const local = newTZDate(TZOffset, 2023, 8, 9, 21, 0); //2023-09-10 02:00:00 UTC
test('returns true when both dates are the same day in UTC', () => {
const utc = newUTC(2023, 8, 10, 0, 0, 0); // September 10, 2023 00:00 UTC

// September 9, 2023 21:00 EDT => September 10, 2023 01:00 UTC
const local = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 9,
hours: 21,
minutes: 0,
});

expect(isSameUTCDay(utc, local)).toBe(true);
});

test('returns false', () => {
const utc = newUTC(2023, 8, 10);
// '2023-09-09T12:00' NY time
const local = newTZDate(TZOffset, 2023, 8, 9, 12, 0); //2023-09-09 17:00:00 UTC
test('returns false when both dates are not the same day in UTC', () => {
const utc = newUTC(2023, 8, 10); // September 10, 2023 00:00 UTC

// September 9, 2023 12:00 EDT => September 9, 2023 16:00 UTC
const local = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 9,
hours: 12,
minutes: 0,
});

expect(isSameUTCDay(utc, local)).toBe(false);
});
});

describe('when both dates are defined locally', () => {
test('returns true', () => {
const local1 = newTZDate(TZOffset, 2023, 8, 8, 20, 0); // 02:00 UTC + 1day
const local2 = newTZDate(TZOffset, 2023, 8, 9, 18, 0); // 23:00 UTC
test('returns true when both dates are the same day in UTC', () => {
// September 8, 2023 20:00 EDT => September 9, 2023 00:00 UTC
const local1 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 8,
hours: 20,
minutes: 0,
});

// September 9, 2023 18:00 EDT => September 9, 2023 22:00 UTC
const local2 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 9,
hours: 18,
minutes: 0,
});
expect(isSameUTCDay(local1, local2)).toBe(true);
});

test('returns false', () => {
const local1 = newTZDate(TZOffset, 2023, 8, 9, 0, 0); // 05:00 UTC
const local2 = newTZDate(TZOffset, 2023, 8, 9, 20, 0); // 02:00 UTC +1 day
test('returns false when both dates are not the same day in UTC', () => {
// September 9, 2023 00:00 EDT => September 9, 2023 04:00 UTC
const local1 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 9,
hours: 0,
minutes: 0,
});

// September 9, 2023 20:00 EDT => September 10, 2023 00:00 UTC
const local2 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: 8,
date: 9,
hours: 20,
minutes: 0,
});

expect(isSameUTCDay(local1, local2)).toBe(false);
});
});
Expand Down
78 changes: 62 additions & 16 deletions packages/date-utils/src/isSameUTCMonth/isSameUTCMonth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,111 @@ import { mockTimeZone } from '../testing/mockTimeZone';

import { isSameUTCMonth } from '.';

const TZOffset = -5;
const TZOffset = -4;
const americaNewYorkTimeZone = 'America/New_York';

describe('packages/date-utils/isSameUTCMonth', () => {
beforeEach(() => {
mockTimeZone('America/New_York', TZOffset);
mockTimeZone(americaNewYorkTimeZone, TZOffset);
});
afterEach(() => {
jest.resetAllMocks();
});

describe('when both dates are defined in UTC', () => {
test('true', () => {
test('returns true when both dates are the same month', () => {
const utc1 = newUTC(2023, Month.September, 1);
const utc2 = newUTC(2023, Month.September, 10);
expect(isSameUTCMonth(utc1, utc2)).toBe(true);
});

test('false', () => {
test('returns false when both dates are not the same month', () => {
const utc1 = newUTC(2023, Month.September, 1);
const utc2 = newUTC(2023, Month.August, 31);
expect(isSameUTCMonth(utc1, utc2)).toBe(false);
});
});

describe('when one date is defined locally', () => {
test('true', () => {
test('returns true when both dates are the same month in UTC', () => {
const utc = newUTC(2023, Month.September, 10);
const local = newTZDate(TZOffset, 2023, Month.August, 31, 21, 0, 0);

// August 31, 2023 21:00 EDT (UTC-4) => September 01, 2023 01:00 UTC
const local = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.August,
date: 31,
hours: 21,
minutes: 0,
});
expect(isSameUTCMonth(utc, local)).toBe(true);
});

test('false', () => {
test('returns false when both dates are not the same month in UTC', () => {
const utc = newUTC(2023, Month.September, 10);
const local = newTZDate(TZOffset, 2023, Month.August, 31, 12, 0);
// August 31, 2023 12:00 EDT (UTC-4) => August 31, 2023 16:00 UTC
const local = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.August,
date: 31,
hours: 12,
minutes: 0,
});
expect(isSameUTCMonth(utc, local)).toBe(false);
});
});

describe(' when both dates are defined locally', () => {
test('true', () => {
const local1 = newTZDate(TZOffset, 2023, Month.September, 1, 0, 0);
const local2 = newTZDate(TZOffset, 2023, Month.September, 30, 18, 0);
test('returns true when both dates are the same month in UTC', () => {
const local1 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.September,
date: 1,
hours: 0,
minutes: 0,
});
const local2 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.September,
date: 30,
hours: 18,
minutes: 0,
});
expect(isSameUTCMonth(local1, local2)).toBe(true);
});

test('false', () => {
const local1 = newTZDate(TZOffset, 2023, Month.September, 1, 0, 0);
const local2 = newTZDate(TZOffset, 2023, Month.September, 30, 20, 0);
test('returns false when both dates are not the same month in UTC', () => {
const local1 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.September,
date: 1,
hours: 0,
minutes: 0,
});
const local2 = newTZDate({
timeZone: americaNewYorkTimeZone,
year: 2023,
month: Month.September,
date: 30,
hours: 20,
minutes: 0,
});
expect(isSameUTCMonth(local1, local2)).toBe(false);
});
});

test('false: when one or both dates is null', () => {
test('returns false when one or both dates is null', () => {
expect(isSameUTCMonth(new Date(), null)).toBe(false);
expect(isSameUTCMonth(null, new Date())).toBe(false);
expect(isSameUTCMonth(null, null)).toBe(false);
});

test('false for different years', () => {
test('returns false for different years', () => {
const utc1 = newUTC(2023, Month.September, 1);
const utc2 = newUTC(2024, Month.September, 10);
expect(isSameUTCMonth(utc1, utc2)).toBe(false);
Expand Down
Loading
Loading