bigblocks
Version:
Complete Bitcoin UI component library - authentication, social, wallet, market, inscriptions, and blockchain interactions for React
33 lines (32 loc) • 978 B
JavaScript
// Social formatting utilities
/**
* Format a timestamp for social media display
*/
export function formatSocialTimestamp(timestamp) {
const now = Date.now();
const diff = now - timestamp;
const minutes = Math.floor(diff / 60000);
const hours = Math.floor(diff / 3600000);
const days = Math.floor(diff / 86400000);
if (minutes < 1)
return "now";
if (minutes < 60)
return `${minutes}m`;
if (hours < 24)
return `${hours}h`;
if (days < 7)
return `${days}d`;
return new Date(timestamp).toLocaleDateString();
}
/**
* Validate social content for posting
*/
export function validateSocialContent(content, maxLength = 280) {
if (!content || content.trim().length === 0) {
return { valid: false, message: "Content cannot be empty" };
}
if (content.length > maxLength) {
return { valid: false, message: `Content exceeds ${maxLength} characters` };
}
return { valid: true };
}