// Helsinki/Europe locale utilities
export const LOCALE_CONFIG = {
  timezone: 'Europe/Helsinki',
  currency: 'EUR',
  language: 'fi-FI'
}

// Date formatting utilities
export const formatDate = (dateString) => {
  if (!dateString) return '-'
  
  const date = new Date(dateString)
  // Use Finnish locale for proper formatting
  return date.toLocaleDateString('fi-FI', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit'
  }).replace(/\./g, '.')
}

export const formatDateTime = (dateString) => {
  if (!dateString) return '-'
  
  const date = new Date(dateString)
  // Use Finnish locale for proper 24-hour formatting
  return date.toLocaleString('fi-FI', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    hour12: false
  }).replace(/\./g, '.')
}

export const formatTime = (dateString) => {
  if (!dateString) return '-'
  
  const date = new Date(dateString)
  // Use Finnish locale for 24-hour time format
  return date.toLocaleTimeString('fi-FI', {
    hour: '2-digit',
    minute: '2-digit',
    hour12: false
  })
}

// Currency formatting utilities
export const formatCurrency = (amount) => {
  if (amount === null || amount === undefined) return '0,00 €'
  
  const numAmount = parseFloat(amount)
  if (isNaN(numAmount)) return '0,00 €'
  
  // Use Finnish locale for proper EUR formatting
  return new Intl.NumberFormat('fi-FI', {
    style: 'currency',
    currency: 'EUR',
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  }).format(numAmount)
}

// Number formatting utilities
export const formatNumber = (number, decimals = 2) => {
  if (number === null || number === undefined) return '0'
  
  const num = parseFloat(number)
  if (isNaN(num)) return '0'
  
  return new Intl.NumberFormat('fi-FI', {
    minimumFractionDigits: decimals,
    maximumFractionDigits: decimals
  }).format(num)
}

// Percentage formatting
export const formatPercentage = (value) => {
  if (value === null || value === undefined) return '0 %'
  
  const num = parseFloat(value)
  if (isNaN(num)) return '0 %'
  
  return new Intl.NumberFormat('fi-FI', {
    style: 'percent',
    minimumFractionDigits: 1,
    maximumFractionDigits: 1
  }).format(num / 100)
}
