@@ -1115,7 +1115,15 @@ impl Duration {
11151115 Ok ( JsString :: from ( result) . into ( ) )
11161116 }
11171117
1118- /// 7.3.24 `Temporal.Duration.prototype.toLocaleString ( )`
1118+ /// 7.3.24 `Temporal.Duration.prototype.toLocaleString ( [ locales [ , options ] ] )`
1119+ ///
1120+ /// When the implementation includes ECMA-402, this method is defined by the Intl specification
1121+ /// (typically via `Intl.DurationFormat`). Boa does not implement `Intl.DurationFormat` yet, so
1122+ /// we use the Temporal proposal **non-ECMA-402** fallback: `TemporalDurationToString(duration, auto)`
1123+ /// — the same string as [`Self::to_json`].
1124+ ///
1125+ /// The `locales` and `options` arguments are accepted for API compatibility but are ignored
1126+ /// until locale-sensitive duration formatting is implemented.
11191127 ///
11201128 /// More information:
11211129 ///
@@ -1126,23 +1134,10 @@ impl Duration {
11261134 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration/toLocaleString
11271135 pub ( crate ) fn to_locale_string (
11281136 this : & JsValue ,
1129- _ : & [ JsValue ] ,
1130- _ : & mut Context ,
1137+ _args : & [ JsValue ] ,
1138+ context : & mut Context ,
11311139 ) -> JsResult < JsValue > {
1132- // TODO: Update for ECMA-402 compliance
1133- let object = this. as_object ( ) ;
1134- let duration = object
1135- . as_ref ( )
1136- . and_then ( JsObject :: downcast_ref :: < Self > )
1137- . ok_or_else ( || {
1138- JsNativeError :: typ ( ) . with_message ( "this value must be a Duration object." )
1139- } ) ?;
1140-
1141- let result = duration
1142- . inner
1143- . as_temporal_string ( ToStringRoundingOptions :: default ( ) ) ?;
1144-
1145- Ok ( JsString :: from ( result) . into ( ) )
1140+ Self :: to_json ( this, & [ ] , context)
11461141 }
11471142
11481143 /// 7.3.25 `Temporal.Duration.prototype.valueOf ( )`
@@ -1156,7 +1151,11 @@ impl Duration {
11561151 /// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration/valueOf
11571152 pub ( crate ) fn value_of ( _this : & JsValue , _: & [ JsValue ] , _: & mut Context ) -> JsResult < JsValue > {
11581153 Err ( JsNativeError :: typ ( )
1159- . with_message ( "`valueOf` not supported by Temporal built-ins. See 'compare', 'equals', or `toString`" )
1154+ . with_message (
1155+ "Cannot convert a Temporal.Duration to a primitive value. \
1156+ Use Temporal.Duration.compare() for comparison or \
1157+ Temporal.Duration.prototype.toString() for a string representation.",
1158+ )
11601159 . into ( ) )
11611160 }
11621161}
0 commit comments