source: frontend/node_modules/es-abstract/2023/GetNamedTimeZoneEpochNanoseconds.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.4 KB
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var GetUTCEpochNanoseconds = require('./GetUTCEpochNanoseconds');
6
7var isInteger = require('math-intrinsics/isInteger');
8
9// https://262.ecma-international.org/14.0/#sec-getnamedtimezoneepochnanoseconds
10
11// eslint-disable-next-line max-params
12module.exports = function GetNamedTimeZoneEpochNanoseconds(
13 timeZoneIdentifier,
14 year,
15 month,
16 day,
17 hour,
18 minute,
19 second,
20 millisecond,
21 microsecond,
22 nanosecond
23) {
24 if (typeof timeZoneIdentifier !== 'string') {
25 throw new $TypeError('Assertion failed: `timeZoneIdentifier` must be a string');
26 }
27 if (!isInteger(year)) {
28 throw new $TypeError('Assertion failed: `year` must be an integral number');
29 }
30 if (!isInteger(month) || month < 1 || month > 12) {
31 throw new $TypeError('Assertion failed: `month` must be an integral number between 1 and 12, inclusive');
32 }
33 if (!isInteger(day) || day < 1 || day > 31) {
34 throw new $TypeError('Assertion failed: `day` must be an integral number between 1 and 31, inclusive');
35 }
36 if (!isInteger(hour) || hour < 0 || hour > 23) {
37 throw new $TypeError('Assertion failed: `hour` must be an integral number between 0 and 23, inclusive');
38 }
39 if (!isInteger(minute) || minute < 0 || minute > 59) {
40 throw new $TypeError('Assertion failed: `minute` must be an integral number between 0 and 59, inclusive');
41 }
42 if (!isInteger(second) || second < 0 || second > 999) {
43 throw new $TypeError('Assertion failed: `second` must be an integral number between 0 and 999, inclusive');
44 }
45 if (!isInteger(millisecond) || millisecond < 0 || millisecond > 999) {
46 throw new $TypeError('Assertion failed: `millisecond` must be an integral number between 0 and 999, inclusive');
47 }
48 if (!isInteger(microsecond) || microsecond < 0 || microsecond > 999) {
49 throw new $TypeError('Assertion failed: `microsecond` must be an integral number between 0 and 999, inclusive');
50 }
51 if (!isInteger(nanosecond) || nanosecond < 0 || nanosecond > 999) {
52 throw new $TypeError('Assertion failed: `nanosecond` must be an integral number between 0 and 999, inclusive');
53 }
54
55 if (timeZoneIdentifier !== 'UTC') {
56 throw new $TypeError('Assertion failed: only UTC time zone is supported'); // step 1
57 }
58
59 var epochNanoseconds = GetUTCEpochNanoseconds(
60 year,
61 month,
62 day,
63 hour,
64 minute,
65 second,
66 millisecond,
67 microsecond,
68 nanosecond
69 ); // step 2
70
71 return [epochNanoseconds]; // step 3
72};
Note: See TracBrowser for help on using the repository browser.