@@ -38,6 +38,7 @@ import {
38
38
List ,
39
39
hop ,
40
40
objCreate ,
41
+ toNumber ,
41
42
arrPush ,
42
43
arrIndexOf
43
44
} from './util.js' ;
@@ -840,14 +841,14 @@ function GetFormatDateTime() {
840
841
// specified for built-in functions in ES5, 15, or successor, and the
841
842
// length property set to 0, that takes the argument date and
842
843
// performs the following steps:
843
- let F = function ( ) {
844
+ let F = function ( date = undefined ) {
844
845
// i. If date is not provided or is undefined, then let x be the
845
846
// result as if by the expression Date.now() where Date.now is
846
847
// the standard built-in function defined in ES5, 15.9.4.4.
847
848
// ii. Else let x be ToNumber(date).
848
849
// iii. Return the result of calling the FormatDateTime abstract
849
850
// operation (defined below) with arguments this and x.
850
- let x = Number ( arguments . length === 0 ? Date . now ( ) : arguments [ 0 ] ) ;
851
+ let x = date === undefined ? Date . now ( ) : toNumber ( date ) ;
851
852
return FormatDateTime ( this , x ) ;
852
853
} ;
853
854
// b. Let bind be the standard built-in function object defined in ES5,
@@ -865,22 +866,22 @@ function GetFormatDateTime() {
865
866
return internal [ '[[boundFormat]]' ] ;
866
867
}
867
868
868
- Intl . DateTimeFormat . prototype . formatToParts = function formatToParts ( ) {
869
+ function formatToParts ( date = undefined ) {
869
870
let internal = this !== null && typeof this === 'object' && getInternalProperties ( this ) ;
870
871
871
872
if ( ! internal || ! internal [ '[[initializedDateTimeFormat]]' ] )
872
873
throw new TypeError ( '`this` value for formatToParts() is not an initialized Intl.DateTimeFormat object.' ) ;
873
874
874
- if ( internal [ '[[boundFormatToParts]]' ] === undefined ) {
875
- let F = function ( ) {
876
- let x = Number ( arguments . length === 0 ? Date . now ( ) : arguments [ 0 ] ) ;
877
- return FormatToPartsDateTime ( this , x ) ;
878
- } ;
879
- let bf = fnBind . call ( F , this ) ;
880
- internal [ '[[boundFormatToParts]]' ] = bf ;
881
- }
882
- return internal [ '[[boundFormatToParts]]' ] ;
883
- } ;
875
+ let x = date === undefined ? Date . now ( ) : toNumber ( date ) ;
876
+ return FormatToPartsDateTime ( this , x ) ;
877
+ }
878
+
879
+ Object . defineProperty ( Intl . DateTimeFormat . prototype , 'formatToParts' , {
880
+ enumerable : false ,
881
+ writable : true ,
882
+ configurable : true ,
883
+ value : formatToParts
884
+ } ) ;
884
885
885
886
function CreateDateTimeParts ( dateTimeFormat , x ) {
886
887
// 1. If x is not a finite Number, then throw a RangeError exception.
0 commit comments