1 | import { ZoneIsAbstractError } from "./errors.js";
|
2 |
|
3 | /**
|
4 | * @interface
|
5 | */
|
6 | export default class Zone {
|
7 | /**
|
8 | * The type of zone
|
9 | * @abstract
|
10 | * @type {string}
|
11 | */
|
12 | get type() {
|
13 | throw new ZoneIsAbstractError();
|
14 | }
|
15 |
|
16 | /**
|
17 | * The name of this zone.
|
18 | * @abstract
|
19 | * @type {string}
|
20 | */
|
21 | get name() {
|
22 | throw new ZoneIsAbstractError();
|
23 | }
|
24 |
|
25 | /**
|
26 | * Returns whether the offset is known to be fixed for the whole year.
|
27 | * @abstract
|
28 | * @type {boolean}
|
29 | */
|
30 | get isUniversal() {
|
31 | throw new ZoneIsAbstractError();
|
32 | }
|
33 |
|
34 | /**
|
35 | * Returns the offset's common name (such as EST) at the specified timestamp
|
36 | * @abstract
|
37 | * @param {number} ts - Epoch milliseconds for which to get the name
|
38 | * @param {Object} opts - Options to affect the format
|
39 | * @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
|
40 | * @param {string} opts.locale - What locale to return the offset name in.
|
41 | * @return {string}
|
42 | */
|
43 | offsetName(ts, opts) {
|
44 | throw new ZoneIsAbstractError();
|
45 | }
|
46 |
|
47 | /**
|
48 | * Returns the offset's value as a string
|
49 | * @abstract
|
50 | * @param {number} ts - Epoch milliseconds for which to get the offset
|
51 | * @param {string} format - What style of offset to return.
|
52 | * Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
53 | * @return {string}
|
54 | */
|
55 | formatOffset(ts, format) {
|
56 | throw new ZoneIsAbstractError();
|
57 | }
|
58 |
|
59 | /**
|
60 | * Return the offset in minutes for this zone at the specified timestamp.
|
61 | * @abstract
|
62 | * @param {number} ts - Epoch milliseconds for which to compute the offset
|
63 | * @return {number}
|
64 | */
|
65 | offset(ts) {
|
66 | throw new ZoneIsAbstractError();
|
67 | }
|
68 |
|
69 | /**
|
70 | * Return whether this Zone is equal to another zone
|
71 | * @abstract
|
72 | * @param {Zone} otherZone - the zone to compare
|
73 | * @return {boolean}
|
74 | */
|
75 | equals(otherZone) {
|
76 | throw new ZoneIsAbstractError();
|
77 | }
|
78 |
|
79 | /**
|
80 | * Return whether this Zone is valid.
|
81 | * @abstract
|
82 | * @type {boolean}
|
83 | */
|
84 | get isValid() {
|
85 | throw new ZoneIsAbstractError();
|
86 | }
|
87 | }
|