| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f0d0084 commit f858c61
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2465,6 +2465,18 @@ OpenSSL crypto support. | |||
| 2465 | 2465 | An attempt was made to use features that require [ICU][], but Node.js was not | |
| 2466 | 2466 | compiled with ICU support. | |
| 2467 | 2467 | ||
| 2468 | + <a id="ERR_NO_TEMPORAL"></a> | ||
| 2469 | + | ||
| 2470 | + ### `ERR_NO_TEMPORAL` | ||
| 2471 | + | ||
| 2472 | + <!-- YAML | ||
| 2473 | + added: REPLACEME | ||
| 2474 | + --> | ||
| 2475 | + | ||
| 2476 | + An attempt was made to use features that require [`Temporal`][], but Node.js was not | ||
| 2477 | + compiled with `Temporal` support or it has been disabled in the current environment | ||
| 2478 | + (for example, when running with `--no-harmony-temporal`). | ||
| 2479 | + | ||
| 2468 | 2480 | <a id="ERR_NO_TYPESCRIPT"></a> | |
| 2469 | 2481 | ||
| 2470 | 2482 | ### `ERR_NO_TYPESCRIPT` | |
@@ -4472,6 +4484,7 @@ An error occurred trying to allocate memory. This should never happen. | |||
| 4472 | 4484 | [`QuicError`]: quic.md#class-quicerror | |
| 4473 | 4485 | [`REPL`]: repl.md | |
| 4474 | 4486 | [`ServerResponse`]: http.md#class-httpserverresponse | |
| 4487 | + [`Temporal`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal | ||
| 4475 | 4488 | [`Writable`]: stream.md#class-streamwritable | |
| 4476 | 4489 | [`child_process`]: child_process.md | |
| 4477 | 4490 | [`cipher.getAuthTag()`]: crypto.md#ciphergetauthtag | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4796,7 +4796,11 @@ Stats { | |||
| 4796 | 4796 | atime: 2019-06-22T03:37:33.072Z, | |
| 4797 | 4797 | mtime: 2019-06-22T03:36:54.583Z, | |
| 4798 | 4798 | ctime: 2019-06-22T03:37:06.624Z, | |
| 4799 | - birthtime: 2019-06-22T03:28:46.937Z | ||
| 4799 | + birthtime: 2019-06-22T03:28:46.937Z, | ||
| 4800 | + atimeInstant: 2019-06-22T03:37:33.071963Z, | ||
| 4801 | + mtimeInstant: 2019-06-22T03:36:54.5833518Z, | ||
| 4802 | + ctimeInstant: 2019-06-22T03:37:06.6235366Z, | ||
| 4803 | + birthtimeInstant: 2019-06-22T03:28:46.9372893Z | ||
| 4800 | 4804 | } | |
| 4801 | 4805 | false | |
| 4802 | 4806 | Stats { | |
@@ -4817,7 +4821,11 @@ Stats { | |||
| 4817 | 4821 | atime: 2019-06-22T03:36:56.619Z, | |
| 4818 | 4822 | mtime: 2019-06-22T03:36:54.584Z, | |
| 4819 | 4823 | ctime: 2019-06-22T03:36:54.584Z, | |
| 4820 | - birthtime: 2019-06-22T03:26:47.711Z | ||
| 4824 | + birthtime: 2019-06-22T03:26:47.711Z, | ||
| 4825 | + atimeInstant: 2019-06-22T03:36:56.6188555Z, | ||
| 4826 | + mtimeInstant: 2019-06-22T03:36:54.584Z, | ||
| 4827 | + ctimeInstant: 2019-06-22T03:36:54.5838145Z, | ||
| 4828 | + birthtimeInstant: 2019-06-22T03:26:47.7107478Z | ||
| 4821 | 4829 | } | |
| 4822 | 4830 | ``` | |
| 4823 | 4831 | ||
@@ -7522,6 +7530,9 @@ i.e. before the `'ready'` event is emitted. | |||
| 7522 | 7530 | <!-- YAML | |
| 7523 | 7531 | added: v0.1.21 | |
| 7524 | 7532 | changes: | |
| 7533 | + - version: REPLACEME | ||
| 7534 | + pr-url: https://github.com/nodejs/node/pull/60789 | ||
| 7535 | + description: Added `Temporal.Instant` support. | ||
| 7525 | 7536 | - version: | |
| 7526 | 7537 | - v22.0.0 | |
| 7527 | 7538 | - v20.13.0 | |
@@ -7557,10 +7568,19 @@ Stats { | |||
| 7557 | 7568 | mtimeMs: 1318289051000.1, | |
| 7558 | 7569 | ctimeMs: 1318289051000.1, | |
| 7559 | 7570 | birthtimeMs: 1318289051000.1, | |
| 7571 | + | ||
| 7572 | + // Instances of Date | ||
| 7560 | 7573 | atime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7561 | 7574 | mtime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7562 | 7575 | ctime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7563 | - birthtime: Mon, 10 Oct 2011 23:24:11 GMT } | ||
| 7576 | + birthtime: Mon, 10 Oct 2011 23:24:11 GMT, | ||
| 7577 | + | ||
| 7578 | + // Instances of Temporal.Instant | ||
| 7579 | + atimeInstant: 2011-10-10T23:24:11.0001Z, | ||
| 7580 | + mtimeInstant: 2011-10-10T23:24:11.0001Z, | ||
| 7581 | + ctimeInstant: 2011-10-10T23:24:11.0001Z, | ||
| 7582 | + birthtimeInstant: 2011-10-10T23:24:11.0001Z | ||
| 7583 | + } | ||
| 7564 | 7584 | ``` | |
| 7565 | 7585 | ||
| 7566 | 7586 | `bigint` version: | |
@@ -7585,10 +7605,19 @@ BigIntStats { | |||
| 7585 | 7605 | mtimeNs: 1318289051000000000n, | |
| 7586 | 7606 | ctimeNs: 1318289051000000000n, | |
| 7587 | 7607 | birthtimeNs: 1318289051000000000n, | |
| 7608 | + | ||
| 7609 | + // Instances of Date | ||
| 7588 | 7610 | atime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7589 | 7611 | mtime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7590 | 7612 | ctime: Mon, 10 Oct 2011 23:24:11 GMT, | |
| 7591 | - birthtime: Mon, 10 Oct 2011 23:24:11 GMT } | ||
| 7613 | + birthtime: Mon, 10 Oct 2011 23:24:11 GMT, | ||
| 7614 | + | ||
| 7615 | + // Instances of Temporal.Instant | ||
| 7616 | + atimeInstant: 2011-10-10T23:24:11Z, | ||
| 7617 | + mtimeInstant: 2011-10-10T23:24:11Z, | ||
| 7618 | + ctimeInstant: 2011-10-10T23:24:11Z, | ||
| 7619 | + birthtimeInstant: 2011-10-10T23:24:11Z | ||
| 7620 | + } | ||
| 7592 | 7621 | ``` | |
| 7593 | 7622 | ||
| 7594 | 7623 | #### `stats.isBlockDevice()` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1639,6 +1639,8 @@ E('ERR_NO_CRYPTO', | |||
| 1639 | 1639 | 'Node.js is not compiled with OpenSSL crypto support', Error); | |
| 1640 | 1640 | E('ERR_NO_ICU', | |
| 1641 | 1641 | '%s is not supported on Node.js compiled without ICU', TypeError); | |
| 1642 | + E('ERR_NO_TEMPORAL', | ||
| 1643 | + 'Temporal is not supported in this environment', Error); | ||
| 1642 | 1644 | E('ERR_NO_TYPESCRIPT', | |
| 1643 | 1645 | 'Node.js is not compiled with TypeScript support', Error); | |
| 1644 | 1646 | E('ERR_OPERATION_FAILED', 'Operation failed: %s', Error, TypeError); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ const { | |||
| 8 | 8 | DatePrototypeGetTime, | |
| 9 | 9 | ErrorCaptureStackTrace, | |
| 10 | 10 | FunctionPrototypeCall, | |
| 11 | + MathFloor, | ||
| 11 | 12 | MathMin, | |
| 12 | 13 | MathRound, | |
| 13 | 14 | Number, | |
@@ -22,6 +23,7 @@ const { | |||
| 22 | 23 | Symbol, | |
| 23 | 24 | TypedArrayPrototypeAt, | |
| 24 | 25 | TypedArrayPrototypeIncludes, | |
| 26 | + globalThis, | ||
| 25 | 27 | } = primordials; | |
| 26 | 28 | ||
| 27 | 29 | const { Buffer } = require('buffer'); | |
@@ -32,6 +34,7 @@ const { | |||
| 32 | 34 | ERR_INCOMPATIBLE_OPTION_PAIR, | |
| 33 | 35 | ERR_INVALID_ARG_TYPE, | |
| 34 | 36 | ERR_INVALID_ARG_VALUE, | |
| 37 | + ERR_NO_TEMPORAL, | ||
| 35 | 38 | ERR_OUT_OF_RANGE, | |
| 36 | 39 | }, | |
| 37 | 40 | hideStackFrames, | |
@@ -43,10 +46,10 @@ const { | |||
| 43 | 46 | isUint8Array, | |
| 44 | 47 | } = require('internal/util/types'); | |
| 45 | 48 | const { | |
| 46 | - kEmptyObject, | ||
| 47 | - once, | ||
| 48 | 49 | deprecate, | |
| 49 | 50 | isWindows, | |
| 51 | + kEmptyObject, | ||
| 52 | + once, | ||
| 50 | 53 | setOwnProperty, | |
| 51 | 54 | } = require('internal/util'); | |
| 52 | 55 | const { toPathIfFileURL } = require('internal/url'); | |
@@ -62,6 +65,10 @@ const { | |||
| 62 | 65 | const pathModule = require('path'); | |
| 63 | 66 | const kType = Symbol('type'); | |
| 64 | 67 | const kStats = Symbol('stats'); | |
| 68 | + const kPartialAtimeNs = Symbol('partialAtimeNs'); | ||
| 69 | + const kPartialMtimeNs = Symbol('partialMtimeNs'); | ||
| 70 | + const kPartialCtimeNs = Symbol('partialCtimeNs'); | ||
| 71 | + const kPartialBirthtimeNs = Symbol('kPartialBirthtimeNs'); | ||
| 65 | 72 | const assert = require('internal/assert'); | |
| 66 | 73 | ||
| 67 | 74 | const { | |
@@ -430,6 +437,25 @@ function nsFromTimeSpecBigInt(sec, nsec) { | |||
| 430 | 437 | return sec * kNsPerSecBigInt + nsec; | |
| 431 | 438 | } | |
| 432 | 439 | ||
| 440 | + // TODO(LiviaMedeiros): TemporalInstant primordial | ||
| 441 | + let TemporalInstant; | ||
| 442 | + | ||
| 443 | + function instantFromNs(nsec) { | ||
| 444 | + TemporalInstant ??= globalThis.Temporal?.Instant; | ||
| 445 | + if (TemporalInstant === undefined) { | ||
| 446 | + throw new ERR_NO_TEMPORAL(); | ||
| 447 | + } | ||
| 448 | + return new TemporalInstant(nsec); | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + function instantFromTimeSpecMs(msec, nsec) { | ||
| 452 | + TemporalInstant ??= globalThis.Temporal?.Instant; | ||
| 453 | + if (TemporalInstant === undefined) { | ||
| 454 | + throw new ERR_NO_TEMPORAL(); | ||
| 455 | + } | ||
| 456 | + return new TemporalInstant(BigInt(MathFloor(msec / kMsPerSec)) * kNsPerSecBigInt + BigInt(nsec)); | ||
| 457 | + } | ||
| 458 | + | ||
| 433 | 459 | // The Date constructor performs Math.floor() on the absolute value | |
| 434 | 460 | // of the timestamp: https://tc39.es/ecma262/#sec-timeclip | |
| 435 | 461 | // Since there may be a precision loss when the timestamp is | |
@@ -490,6 +516,106 @@ const lazyDateFields = { | |||
| 490 | 516 | }, | |
| 491 | 517 | }; | |
| 492 | 518 | ||
| 519 | + const lazyTemporalFields = { | ||
| 520 | + __proto__: null, | ||
| 521 | + atimeInstant: { | ||
| 522 | + __proto__: null, | ||
| 523 | + enumerable: true, | ||
| 524 | + configurable: true, | ||
| 525 | + get() { | ||
| 526 | + return setOwnProperty(this, 'atimeInstant', | ||
| 527 | + instantFromTimeSpecMs(this.atimeMs, this[kPartialAtimeNs])); | ||
| 528 | + }, | ||
| 529 | + set(value) { | ||
| 530 | + setOwnProperty(this, 'atimeInstant', value); | ||
| 531 | + }, | ||
| 532 | + }, | ||
| 533 | + mtimeInstant: { | ||
| 534 | + __proto__: null, | ||
| 535 | + enumerable: true, | ||
| 536 | + configurable: true, | ||
| 537 | + get() { | ||
| 538 | + return setOwnProperty(this, 'mtimeInstant', | ||
| 539 | + instantFromTimeSpecMs(this.mtimeMs, this[kPartialMtimeNs])); | ||
| 540 | + }, | ||
| 541 | + set(value) { | ||
| 542 | + setOwnProperty(this, 'mtimeInstant', value); | ||
| 543 | + }, | ||
| 544 | + }, | ||
| 545 | + ctimeInstant: { | ||
| 546 | + __proto__: null, | ||
| 547 | + enumerable: true, | ||
| 548 | + configurable: true, | ||
| 549 | + get() { | ||
| 550 | + return setOwnProperty(this, 'ctimeInstant', | ||
| 551 | + instantFromTimeSpecMs(this.ctimeMs, this[kPartialCtimeNs])); | ||
| 552 | + }, | ||
| 553 | + set(value) { | ||
| 554 | + setOwnProperty(this, 'ctimeInstant', value); | ||
| 555 | + }, | ||
| 556 | + }, | ||
| 557 | + birthtimeInstant: { | ||
| 558 | + __proto__: null, | ||
| 559 | + enumerable: true, | ||
| 560 | + configurable: true, | ||
| 561 | + get() { | ||
| 562 | + return setOwnProperty(this, 'birthtimeInstant', | ||
| 563 | + instantFromTimeSpecMs(this.birthtimeMs, this[kPartialBirthtimeNs])); | ||
| 564 | + }, | ||
| 565 | + set(value) { | ||
| 566 | + setOwnProperty(this, 'birthtimeInstant', value); | ||
| 567 | + }, | ||
| 568 | + }, | ||
| 569 | + }; | ||
| 570 | + | ||
| 571 | + const lazyTemporalBigIntFields = { | ||
| 572 | + __proto__: null, | ||
| 573 | + atimeInstant: { | ||
| 574 | + __proto__: null, | ||
| 575 | + enumerable: true, | ||
| 576 | + configurable: true, | ||
| 577 | + get() { | ||
| 578 | + return setOwnProperty(this, 'atimeInstant', instantFromNs(this.atimeNs)); | ||
| 579 | + }, | ||
| 580 | + set(value) { | ||
| 581 | + setOwnProperty(this, 'atimeInstant', value); | ||
| 582 | + }, | ||
| 583 | + }, | ||
| 584 | + mtimeInstant: { | ||
| 585 | + __proto__: null, | ||
| 586 | + enumerable: true, | ||
| 587 | + configurable: true, | ||
| 588 | + get() { | ||
| 589 | + return setOwnProperty(this, 'mtimeInstant', instantFromNs(this.mtimeNs)); | ||
| 590 | + }, | ||
| 591 | + set(value) { | ||
| 592 | + setOwnProperty(this, 'mtimeInstant', value); | ||
| 593 | + }, | ||
| 594 | + }, | ||
| 595 | + ctimeInstant: { | ||
| 596 | + __proto__: null, | ||
| 597 | + enumerable: true, | ||
| 598 | + configurable: true, | ||
| 599 | + get() { | ||
| 600 | + return setOwnProperty(this, 'ctimeInstant', instantFromNs(this.ctimeNs)); | ||
| 601 | + }, | ||
| 602 | + set(value) { | ||
| 603 | + setOwnProperty(this, 'ctimeInstant', value); | ||
| 604 | + }, | ||
| 605 | + }, | ||
| 606 | + birthtimeInstant: { | ||
| 607 | + __proto__: null, | ||
| 608 | + enumerable: true, | ||
| 609 | + configurable: true, | ||
| 610 | + get() { | ||
| 611 | + return setOwnProperty(this, 'birthtimeInstant', instantFromNs(this.birthtimeNs)); | ||
| 612 | + }, | ||
| 613 | + set(value) { | ||
| 614 | + setOwnProperty(this, 'birthtimeInstant', value); | ||
| 615 | + }, | ||
| 616 | + }, | ||
| 617 | + }; | ||
| 618 | + | ||
| 493 | 619 | function BigIntStats(dev, mode, nlink, uid, gid, rdev, blksize, | |
| 494 | 620 | ino, size, blocks, | |
| 495 | 621 | atimeNs, mtimeNs, ctimeNs, birthtimeNs) { | |
@@ -508,6 +634,7 @@ function BigIntStats(dev, mode, nlink, uid, gid, rdev, blksize, | |||
| 508 | 634 | ObjectSetPrototypeOf(BigIntStats.prototype, StatsBase.prototype); | |
| 509 | 635 | ObjectSetPrototypeOf(BigIntStats, StatsBase); | |
| 510 | 636 | ObjectDefineProperties(BigIntStats.prototype, lazyDateFields); | |
| 637 | + ObjectDefineProperties(BigIntStats.prototype, lazyTemporalBigIntFields); | ||
| 511 | 638 | ||
| 512 | 639 | BigIntStats.prototype._checkModeProperty = function(property) { | |
| 513 | 640 | if (isWindows && (property === S_IFIFO || property === S_IFBLK || | |
@@ -519,18 +646,23 @@ BigIntStats.prototype._checkModeProperty = function(property) { | |||
| 519 | 646 | ||
| 520 | 647 | function Stats(dev, mode, nlink, uid, gid, rdev, blksize, | |
| 521 | 648 | ino, size, blocks, | |
| 522 | - atimeMs, mtimeMs, ctimeMs, birthtimeMs) { | ||
| 649 | + atimeS, atimeNs, mtimeS, mtimeNs, ctimeS, ctimeNs, birthtimeS, birthtimeNs) { | ||
| 523 | 650 | FunctionPrototypeCall(StatsBase, this, dev, mode, nlink, uid, gid, rdev, | |
| 524 | 651 | blksize, ino, size, blocks); | |
| 525 | - this.atimeMs = atimeMs; | ||
| 526 | - this.mtimeMs = mtimeMs; | ||
| 527 | - this.ctimeMs = ctimeMs; | ||
| 528 | - this.birthtimeMs = birthtimeMs; | ||
| 652 | + this.atimeMs = msFromTimeSpec(atimeS, atimeNs); | ||
| 653 | + this.mtimeMs = msFromTimeSpec(mtimeS, mtimeNs); | ||
| 654 | + this.ctimeMs = msFromTimeSpec(ctimeS, ctimeNs); | ||
| 655 | + this.birthtimeMs = msFromTimeSpec(birthtimeS, birthtimeNs); | ||
| 656 | + this[kPartialAtimeNs] = atimeNs; | ||
| 657 | + this[kPartialMtimeNs] = mtimeNs; | ||
| 658 | + this[kPartialCtimeNs] = ctimeNs; | ||
| 659 | + this[kPartialBirthtimeNs] = birthtimeNs; | ||
| 529 | 660 | } | |
| 530 | 661 | ||
| 531 | 662 | ObjectSetPrototypeOf(Stats.prototype, StatsBase.prototype); | |
| 532 | 663 | ObjectSetPrototypeOf(Stats, StatsBase); | |
| 533 | 664 | ObjectDefineProperties(Stats.prototype, lazyDateFields); | |
| 665 | + ObjectDefineProperties(Stats.prototype, lazyTemporalFields); | ||
| 534 | 666 | ||
| 535 | 667 | Stats.prototype._checkModeProperty = function(property) { | |
| 536 | 668 | if (isWindows && (property === S_IFIFO || property === S_IFBLK || | |
@@ -563,10 +695,10 @@ function getStatsFromBinding(stats, offset = 0) { | |||
| 563 | 695 | stats[3 + offset], stats[4 + offset], stats[5 + offset], | |
| 564 | 696 | stats[6 + offset], stats[7 + offset], stats[8 + offset], | |
| 565 | 697 | stats[9 + offset], | |
| 566 | - msFromTimeSpec(stats[10 + offset], stats[11 + offset]), | ||
| 567 | - msFromTimeSpec(stats[12 + offset], stats[13 + offset]), | ||
| 568 | - msFromTimeSpec(stats[14 + offset], stats[15 + offset]), | ||
| 569 | - msFromTimeSpec(stats[16 + offset], stats[17 + offset]), | ||
| 698 | + stats[10 + offset], stats[11 + offset], // atime | ||
| 699 | + stats[12 + offset], stats[13 + offset], // mtime | ||
| 700 | + stats[14 + offset], stats[15 + offset], // ctime | ||
| 701 | + stats[16 + offset], stats[17 + offset], // birthtime | ||
| 570 | 702 | ); | |
| 571 | 703 | } | |
| 572 | 704 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments