time-zone.ts 521 B

1234567891011121314
  1. /** Browser-owned time-zone sampling for prompt RPC provenance. */
  2. /**
  3. * Resolve the current browser IANA zone for one outbound operation.
  4. * @returns The browser-provided canonical zone.
  5. * @throws when the runtime cannot provide a non-empty zone.
  6. */
  7. export function resolvedClientTimeZone(): string {
  8. const timeZone = new Intl.DateTimeFormat().resolvedOptions().timeZone
  9. if (typeof timeZone !== 'string' || timeZone.length === 0) {
  10. throw new Error('browser time zone is unavailable')
  11. }
  12. return timeZone
  13. }