Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
anishpawaskar committed Oct 28, 2023
1 parent 738a730 commit 7cb94ac
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/helperFunctions/getIdleSinceText.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { TOTAL_MILLISECONDS_IN_A_HOUR } from '@/constants/date';

const getIdleSinceText = (idleSince: string) => {
const presentDate = new Date();
const idleSinceDate = new Date(idleSince);
const presentDateInUtc = new Date().toUTCString();
const idleSinceDateInUtc = new Date(idleSince).toUTCString();

const presentDateInUtc = presentDate.toUTCString();
const idleSinceDateInUtc = idleSinceDate.toUTCString();
const presentDate = new Date(presentDateInUtc).valueOf();
const idleSinceDate = new Date(idleSinceDateInUtc).valueOf();

const differenceInHours = Math.round(
(new Date(presentDateInUtc).valueOf() -
new Date(idleSinceDateInUtc).valueOf()) /
TOTAL_MILLISECONDS_IN_A_HOUR
(presentDate - idleSinceDate) / TOTAL_MILLISECONDS_IN_A_HOUR
);
const idealDays = Math.round(differenceInHours / 24);

Expand Down

0 comments on commit 7cb94ac

Please sign in to comment.