function ensureTimestampInSeconds(timestamp) {
  const isMs = timestamp > 9999999999;
  return isMs ? timestamp / 1000 : timestamp;
}
Converts a timestamp to second, if it was in milliseconds, or keeps it as second.