SystemTimeZoneIdentifier.js 526 B

123456789101112131415161718
  1. 'use strict';
  2. var callBind = require('call-bind');
  3. var I402 = typeof Intl === 'undefined' ? null : Intl;
  4. var DateTimeFormat = I402 && I402.DateTimeFormat;
  5. var resolvedOptions = DateTimeFormat && callBind(DateTimeFormat.prototype.resolvedOptions);
  6. // https://262.ecma-international.org/15.0/#sec-systemtimezoneidentifier
  7. module.exports = function SystemTimeZoneIdentifier() {
  8. if (DateTimeFormat && resolvedOptions) {
  9. return resolvedOptions(new DateTimeFormat()).timeZone; // steps 2 - 3
  10. }
  11. return 'UTC'; // step 1
  12. };