@bze/bze-ui-kit 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -678,11 +678,28 @@ var formatTimeRemaining = (targetDate) => {
|
|
|
678
678
|
if (minutes > 0) parts.push(`${minutes}m`);
|
|
679
679
|
return parts.join(" ") || "Now";
|
|
680
680
|
};
|
|
681
|
-
|
|
682
|
-
|
|
681
|
+
function formatTimeRemainingFromEpochs(endEpoch, currentEpoch) {
|
|
682
|
+
let epochDiff;
|
|
683
|
+
if (currentEpoch !== void 0) {
|
|
684
|
+
const endBN = toBigNumber(endEpoch);
|
|
685
|
+
const currentBN = toBigNumber(currentEpoch);
|
|
686
|
+
epochDiff = endBN.minus(currentBN);
|
|
687
|
+
if (epochDiff.lte(0)) {
|
|
688
|
+
return "Ended";
|
|
689
|
+
}
|
|
690
|
+
const hoursRemaining = epochDiff.toNumber();
|
|
691
|
+
const daysRemaining = Math.floor(hoursRemaining / 24);
|
|
692
|
+
const hoursRemainder = hoursRemaining % 24;
|
|
693
|
+
if (daysRemaining > 0) {
|
|
694
|
+
return `${daysRemaining}d ${hoursRemainder}h`;
|
|
695
|
+
}
|
|
696
|
+
return `${hoursRemainder}h`;
|
|
697
|
+
}
|
|
698
|
+
epochDiff = toBigNumber(endEpoch);
|
|
699
|
+
if (epochDiff.lte(0)) {
|
|
683
700
|
return "Now";
|
|
684
701
|
}
|
|
685
|
-
const totalSeconds =
|
|
702
|
+
const totalSeconds = epochDiff.multipliedBy(60).toNumber();
|
|
686
703
|
const days = Math.floor(totalSeconds / (60 * 60 * 24));
|
|
687
704
|
const hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
|
|
688
705
|
const minutes = Math.floor(totalSeconds % (60 * 60) / 60);
|
|
@@ -691,7 +708,7 @@ var formatTimeRemainingFromEpochs = (epochs) => {
|
|
|
691
708
|
if (hours > 0) parts.push(`${hours}h`);
|
|
692
709
|
if (minutes > 0) parts.push(`${minutes}m`);
|
|
693
710
|
return parts.join(" ") || "Now";
|
|
694
|
-
}
|
|
711
|
+
}
|
|
695
712
|
|
|
696
713
|
// src/utils/functions.ts
|
|
697
714
|
async function sleep(ms) {
|