All files / src/zones localZone.js

84.62% Statements 11/13
44.44% Branches 4/9
87.5% Functions 7/8
84.62% Lines 11/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49        32x               804x 19x   804x       370x       2x   2x       13x               4319x       322x       1730x      
import { Util } from '../impl/util';
import { Zone } from '../zone';
import { Settings } from '../settings';
 
let singleton = null;
 
/**
 * @private
 */
 
export class LocalZone extends Zone {
  static get instance() {
    if (singleton === null) {
      singleton = new LocalZone();
    }
    return singleton;
  }
 
  get type() {
    return 'local';
  }
 
  get name() {
    Iif (Util.isUndefined(Intl) && Util.isUndefined(Intl.DateTimeFormat)) {
      return new Intl.DateTimeFormat().resolvedOptions().timeZone;
    } else return 'local';
  }
 
  get universal() {
    return false;
  }
 
  offsetName(ts, { format = 'long', locale = Settings.defaultLocale } = {}) {
    return Util.parseZoneInfo(ts, format, locale);
  }
 
  offset(ts) {
    return -new Date(ts).getTimezoneOffset();
  }
 
  equals(otherZone) {
    return otherZone.type === 'local';
  }
 
  get isValid() {
    return true;
  }
}