Skip to content

Commit

Permalink
MEP v1.0.15
Browse files Browse the repository at this point in the history
MEP v1.0.15
  • Loading branch information
Minishlink authored Nov 27, 2017
2 parents e24ebb2 + cc21a24 commit 3d41bed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
4 changes: 2 additions & 2 deletions fastlane/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_VERSION_CODE='14'
APP_VERSION_NAME='1.0.14'
APP_VERSION_CODE='15'
APP_VERSION_NAME='1.0.15'
6 changes: 5 additions & 1 deletion src/components/TrelloCard/TrelloCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export default class extends Component<Props> {
render() {
const { card } = this.props;
const validationLatenessInDays =
card.dateEndDevelopment && differenceInBusinessDays(card.dateDone || Date.now(), card.dateEndDevelopment);
card.dateEndDevelopment &&
differenceInBusinessDays(
(card.dateDone && new Date(card.dateDone).getTime()) || Date.now(),
new Date(card.dateEndDevelopment).getTime()
);

return (
<Button style={this.props.style} onLongPress={this.showActionSheet}>
Expand Down
16 changes: 14 additions & 2 deletions src/services/Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,27 @@ export const isDateEqual = (a: Date, b: Date) => isEqual(a.setHours(0, 0, 0, 0),
export const differenceInBusinessDays = (aTime: number, bTime: number): number => {
let a = new Date(aTime);
setDateWithBoundary(a);

// handle case where the validation was made during the morning before the boundary
if (aTime < a.getTime()) {
a = new Date(aTime - ONE_DAY);
a = new Date(a.getTime() - ONE_DAY);
}

// handle Sunday
if (a.getDay() === 0) {
a = new Date(a.getTime() - ONE_DAY);
}

// handle Saturday
if (a.getDay() === 6) {
a = new Date(a.getTime() - ONE_DAY);
}

const b = new Date(bTime);
setDateWithBoundary(b);

let days = 0;
if (b.getTime() === a.getTime()) {
if (b.getTime() >= a.getTime()) {
return days;
}

Expand Down
19 changes: 16 additions & 3 deletions src/services/__tests__/Time.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { differenceInBusinessDays, getLastWorkableDayTime, getTodayWorkableDayTi
describe('Time', () => {
describe('differenceInBusinessDays', () => {
const baseDateTime = new Date('2017-11-13T10:45:00.000Z').getTime();
it('returns 0', () => {
expect(
differenceInBusinessDays(
new Date('2017-11-27T08:20:46.369Z').getTime(),
new Date('2017-11-24T15:50:57.722Z').getTime()
)
).toEqual(0);
});

it('returns 0 on the same day', () => {
expect(differenceInBusinessDays(baseDateTime, baseDateTime)).toEqual(0);
});
Expand Down Expand Up @@ -31,12 +40,16 @@ describe('Time', () => {
expect(differenceInBusinessDays(new Date('2017-11-17T09:00:00.000Z').getTime(), baseDateTime)).toEqual(3);
});

it('returns 3 after four days, after the daily', () => {
it('returns 4 after four days, after the daily', () => {
expect(differenceInBusinessDays(new Date('2017-11-17T11:00:00.000Z').getTime(), baseDateTime)).toEqual(4);
});

it('returns 5 after one week', () => {
expect(differenceInBusinessDays(new Date('2017-11-20').getTime(), baseDateTime)).toEqual(5);
it('returns 4 after one week, before the daily', () => {
expect(differenceInBusinessDays(new Date('2017-11-20T08:00:00.000Z').getTime(), baseDateTime)).toEqual(4);
});

it('returns 5 after one week, after the daily', () => {
expect(differenceInBusinessDays(new Date('2017-11-20T11:00:00.000Z').getTime(), baseDateTime)).toEqual(5);
});
});

Expand Down

0 comments on commit 3d41bed

Please sign in to comment.