Skip to content

Commit

Permalink
Merge pull request #1841 from bcgov/feature/ALCS-2048-2
Browse files Browse the repository at this point in the history
Fix Timezone Difference Issue
  • Loading branch information
Abradat authored Sep 10, 2024
2 parents 56609b2 + 221f3db commit 56875c0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions services/apps/alcs/src/alcs/admin/holiday/holiday.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InjectRepository } from '@nestjs/typeorm';
import { Between, FindOptionsWhere, Repository } from 'typeorm';
import { HolidayCreateDto, HolidayUpdateDto } from './holiday.dto';
import { HolidayEntity } from './holiday.entity';
import { getStartOfDayToPacific } from '../../../utils/pacific-date-time-helper';

@Injectable()
export class HolidayService {
Expand Down Expand Up @@ -105,8 +106,10 @@ export class HolidayService {
};

const differenceInDays = (startDate: Date, endDate: Date): number => {
const timeDiff = endDate.getTime() - startDate.getTime();
return Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
const timeDiff =
getStartOfDayToPacific(endDate.getTime()).getTime() -
getStartOfDayToPacific(startDate.getTime()).getTime();
return Math.floor(timeDiff / (1000 * 60 * 60 * 24));
};

const totalDays = differenceInDays(fromDate, toDate) + 1;
Expand Down

0 comments on commit 56875c0

Please sign in to comment.