Skip to content

Commit

Permalink
Merge branch 'master' of github.com:wix/react-native-calendars into r…
Browse files Browse the repository at this point in the history
…elease
  • Loading branch information
Inbal-Tish committed Feb 26, 2024
2 parents cbed31f + d06080c commit 29dacf5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
32 changes: 32 additions & 0 deletions src/dateutils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ describe('dateutils', function () {
});

describe('isLTE()', function () {
it('a is undefined', function () {
const a = undefined;
const b = XDate(2014, 1, 20);
expect(isLTE(b, a)).toBe(undefined);
});

it('b is undefined', function () {
const a = XDate(2013, 12, 31);
const b = undefined;
expect(isLTE(b, a)).toBe(undefined);
});

it('both are undefined', function () {
expect(isLTE(undefined, undefined)).toBe(undefined);
});

it('2014-01-20 >= 2013-12-31', function () {
const a = XDate(2013, 12, 31);
const b = XDate(2014, 1, 20);
Expand Down Expand Up @@ -98,6 +114,22 @@ describe('dateutils', function () {
});

describe('isGTE()', function () {
it('a is undefined', function () {
const a = undefined;
const b = XDate(2014, 1, 20);
expect(isGTE(b, a)).toBe(undefined);
});

it('b is undefined', function () {
const a = XDate(2013, 12, 31);
const b = undefined;
expect(isGTE(b, a)).toBe(undefined);
});

it('both are undefined', function () {
expect(isGTE(undefined, undefined)).toBe(undefined);
});

it('2014-01-20 >= 2013-12-31', function () {
const a = XDate(2013, 12, 31);
const b = XDate(2014, 1, 20);
Expand Down
8 changes: 6 additions & 2 deletions src/dateutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ export function isToday(date?: XDate | string) {
}

export function isGTE(a: XDate, b: XDate) {
return b.diffDays(a) > -1;
if (a && b) {
return b.diffDays(a) > -1;
}
}

export function isLTE(a: XDate, b: XDate) {
return a.diffDays(b) > -1;
if (a && b) {
return a.diffDays(b) > -1;
}
}

export function formatNumbers(date: any) {
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function xdateToData(date: XDate | string) {
}

export function parseDate(d?: any) {
if (!d) {
if (d === undefined) {
return;
} else if (d.timestamp) {
// conventional data timestamp
Expand Down
1 change: 1 addition & 0 deletions src/timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const Timeline = (props: TimelineProps) => {
width={width}
numberOfDays={numberOfDays}
timelineLeftInset={timelineLeftInset}
testID={`${testID}.hours`}
/>
{times(numberOfDays, renderTimelineDay)}
</ScrollView>
Expand Down
6 changes: 5 additions & 1 deletion src/timeline/TimelineHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface TimelineHoursProps {
width: number;
numberOfDays: number;
timelineLeftInset?: number;
testID?: string;
}

const dimensionWidth = constants.screenWidth;
Expand All @@ -45,7 +46,8 @@ const TimelineHours = (props: TimelineHoursProps) => {
onBackgroundLongPressOut,
width,
numberOfDays = 1,
timelineLeftInset = 0
timelineLeftInset = 0,
testID,
} = props;

const lastLongPressEventTime = useRef<NewEventTime>();
Expand Down Expand Up @@ -121,12 +123,14 @@ const TimelineHours = (props: TimelineHoursProps) => {
{time === start ? null : (
<View
key={`line${time}`}
testID={`${testID}.${time}.line`}
style={[styles.line, {top: offset * index, width: dimensionWidth - EVENT_DIFF, left: timelineLeftInset - 16}]}
/>
)}
{
<View
key={`lineHalf${time}`}
testID={`${testID}.${time}.lineHalf`}
style={[styles.line, {top: offset * (index + 0.5), width: dimensionWidth - EVENT_DIFF, left: timelineLeftInset - 16}]}
/>
}
Expand Down

0 comments on commit 29dacf5

Please sign in to comment.