UNPKG

@oxyhq/services

Version:

OxyHQ Expo/React Native SDK — UI components, screens, and native features

46 lines (42 loc) 1.17 kB
"use strict"; /** * User display name and date formatting utilities */ /** * Formats a date string to a readable format (e.g., "Feb 21, 2025") */ export const formatDate = dateString => { if (!dateString) return ''; try { const date = dateString instanceof Date ? dateString : new Date(dateString); if (isNaN(date.getTime())) return ''; return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }); } catch { return ''; } }; /** * Gets a display name from user data */ export const getDisplayName = user => { if (!user) return 'User'; const fullName = user.name?.full; if (fullName) return fullName; const firstLast = [user.name?.first, user.name?.last].filter(Boolean).join(' ').trim(); if (firstLast) return firstLast; return user.username || 'User'; }; /** * Gets a short display name (first name or username) */ export const getShortDisplayName = user => { if (!user) return 'User'; const firstName = user.name?.first || user.name?.full?.split(' ')[0]; if (firstName) return firstName; return user.username || 'User'; }; //# sourceMappingURL=userUtils.js.map