bugfixing formatDate
This commit is contained in:
parent
3ed90fb700
commit
84c70cd287
@ -748,7 +748,6 @@ export function abbreviateNumber(number, addDollarSign = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function formatDate(dateStr) {
|
export function formatDate(dateStr) {
|
||||||
try {
|
try {
|
||||||
// Parse the input date string in New York timezone
|
// Parse the input date string in New York timezone
|
||||||
@ -772,16 +771,18 @@ export function formatDate(dateStr) {
|
|||||||
|
|
||||||
const nyDateObj = parseDate(new Date(dateStr));
|
const nyDateObj = parseDate(new Date(dateStr));
|
||||||
const nyCurrentObj = parseDate(new Date());
|
const nyCurrentObj = parseDate(new Date());
|
||||||
|
|
||||||
// Calculate the time difference in seconds
|
// Calculate the time difference in seconds
|
||||||
const seconds = Math.floor((nyCurrentObj - nyDateObj) / 1000);
|
const seconds = Math.floor((nyCurrentObj - nyDateObj) / 1000);
|
||||||
|
|
||||||
// Define time intervals in seconds
|
// Define time intervals in seconds
|
||||||
const intervals = [
|
const intervals = [
|
||||||
{ unit: 'year', seconds: 31536000 },
|
{ unit: 'year', seconds: 31536000 },
|
||||||
{ unit: 'month', seconds: 2592000 },
|
{ unit: 'month', seconds: 2592000 },
|
||||||
{ unit: 'week', seconds: 604800 },
|
{ unit: 'week', seconds: 604800 },
|
||||||
{ unit: 'day', seconds: 86400 }
|
{ unit: 'day', seconds: 86400 },
|
||||||
|
{ unit: 'hour', seconds: 3600 },
|
||||||
|
{ unit: 'minute', seconds: 60 },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Determine the appropriate time interval
|
// Determine the appropriate time interval
|
||||||
@ -791,8 +792,7 @@ export function formatDate(dateStr) {
|
|||||||
return `${count} ${unit}${count === 1 ? '' : 's'} ago`;
|
return `${count} ${unit}${count === 1 ? '' : 's'} ago`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// If less than a minute
|
||||||
// If less than a day, return "Just now"
|
|
||||||
return 'Just now';
|
return 'Just now';
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error formatting date:', error);
|
console.error('Error formatting date:', error);
|
||||||
@ -802,6 +802,7 @@ export function formatDate(dateStr) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const formatRuleValue = (rule) => {
|
export const formatRuleValue = (rule) => {
|
||||||
if (["interestIncome", "interestExpenses"].includes(rule.name)) {
|
if (["interestIncome", "interestExpenses"].includes(rule.name)) {
|
||||||
return `$${rule.value === 1000 ? `${rule.value / 1000} Bn` : `${rule.value} Mio`}`;
|
return `$${rule.value === 1000 ? `${rule.value / 1000} Bn` : `${rule.value} Mio`}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user