const earthYears = {
  mercury: 0.2408467,
  venus: 0.61519726,
  earth: 1.0,
  mars: 1.8808158,
  jupiter: 11.862615,
  saturn: 29.447498,
  uranus: 84.016846,
  neptune: 164.79132,
} as const;

type Planet = keyof typeof earthYears;

const roundTwoDecimals = (num: number): number => Math.round(num * 100) / 100;

export function age(planet: Planet, seconds: number): number {
  const minutes = seconds / 60;
  const hours = minutes / 60;
  const days = hours / 24;
  const years = days / 365.25;
  return roundTwoDecimals(years / earthYears[planet]);
}
