Skip to content

Commit

Permalink
Merge pull request #287 from Toniq-Labs/launchpad-duration-fix
Browse files Browse the repository at this point in the history
Duration fixes
  • Loading branch information
ponnexcodev authored Sep 9, 2023
2 parents c76c14a + 08ed9d5 commit 41a207a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/typescript/augments/duration-date.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import moment from 'moment';

export function getDurationDate(date: number) {
const dateDuration: moment.Duration = moment.duration(moment(date).diff(moment()));
var days = parseInt(dateDuration.asDays().toFixed(2));
var hours = parseInt(dateDuration.asHours().toFixed(2)) - days * 24;
var minutes = parseInt(dateDuration.asMinutes().toFixed(2)) - (days * 24 * 60 + hours * 60);

return {
days,
hours,
minutes,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from '@toniq-labs/design-system';
import {BigNumber} from 'bignumber.js';
import {truncateNumber} from '@augment-vir/common';
import moment, {duration} from 'moment';
import moment from 'moment';
import {getDurationDate} from '../../../../augments/duration-date';

type StatsArray = {
title: string;
Expand Down Expand Up @@ -95,7 +96,7 @@ export const EntrepotSaleCardElement = defineElement<{
height: 100%;
}
:host(:hover) {
.card-button:hover > .card-wrapper {
border-color: ${toniqColors.pageInteraction.foregroundColor};
}
Expand Down Expand Up @@ -266,8 +267,8 @@ export const EntrepotSaleCardElement = defineElement<{
function formattedDate(date: number) {
if (moment(date).isBefore(moment()))
return inputs.dateMessage ? inputs.dateMessage : 'Just Ended';
const dateDuration: any = duration(moment(date).diff(moment()));
const {days, hours, minutes} = dateDuration._data;
const {days, hours, minutes} = getDurationDate(date);

return html`
<span class="launch-time-unit">
${days}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from '@toniq-labs/design-system';
import {BigNumber} from 'bignumber.js';
import {truncateNumber} from '@augment-vir/common';
import moment, {duration} from 'moment';
import moment from 'moment';
import {getDurationDate} from '../../../../augments/duration-date';

type StatsArray = {
title: string;
Expand Down Expand Up @@ -302,8 +303,8 @@ export const EntrepotSaleCategoryCardElement = defineElement<{
function formattedDate(date: number) {
if (moment(date).isBefore(moment()))
return inputs.dateMessage ? inputs.dateMessage : 'Just Ended';
const dateDuration: any = duration(moment(date).diff(moment()));
const {days, hours, minutes} = dateDuration._data;
const {days, hours, minutes} = getDurationDate(date);

return html`
<span class="launch-time-unit">
${days}
Expand Down

0 comments on commit 41a207a

Please sign in to comment.