@@ -210,6 +210,71 @@ export default function polyfill(globalSpace) {
210210 }
211211 } ) ;
212212
213+ const _formatToParts = _get (
214+ DateTimeFormatPolyfill . prototype . __proto__ ||
215+ Object . getPrototypeOf ( DateTimeFormatPolyfill . prototype ) ,
216+ 'formatToParts' ,
217+ this
218+ ) ;
219+
220+ if ( _formatToParts ) {
221+ Object . defineProperty ( DateTimeFormatPolyfill . prototype , 'formatToParts' , {
222+ configurable : true ,
223+ value : function ( date ) {
224+
225+ const _resolvedOptions = _get (
226+ DateTimeFormatPolyfill . prototype . __proto__ ||
227+ Object . getPrototypeOf ( DateTimeFormatPolyfill . prototype ) ,
228+ 'resolvedOptions' ,
229+ this
230+ ) ;
231+
232+ if ( ! this . _dateTimeFormatPolyfill ) {
233+ return _formatToParts . call ( this , date ) ;
234+ }
235+
236+ if ( date === null || date === undefined ) {
237+ date = new Date ( ) ;
238+ }
239+
240+ if ( ! ( date instanceof Date ) ) {
241+ date = new Date ( date ) ;
242+ }
243+
244+ const polyfill = this . _dateTimeFormatPolyfill ;
245+ const timeZoneOffsetInfo = getTimeZoneOffsetInfo ( polyfill . timeZoneData , date ) ;
246+ const timeZoneOffset = timeZoneOffsetInfo . offset * 60000 ;
247+ const shiftedDate = new Date ( date . getTime ( ) + timeZoneOffset ) ; // We need to format time by offseting it
248+ const shiftedParts = _formatToParts . call ( this , shiftedDate ) ;
249+ const resolvedLocale = _resolvedOptions . call ( this ) . locale ;
250+ const doNeedToReplaceTimeZoneName = ( polyfill . optionTimeZoneName !== undefined ) ;
251+
252+ if ( doNeedToReplaceTimeZoneName ) {
253+ const isShort = ( polyfill . optionTimeZoneName === 'short' ) ;
254+ const timeZoneName = getZoneNameForLocale ( {
255+ locale : resolvedLocale ,
256+ ianaTimeZone : polyfill . optionTimeZone ,
257+ isdst : timeZoneOffsetInfo . isdst ,
258+ offset : timeZoneOffsetInfo . offset ,
259+ timeStamp : date . getTime ( ) ,
260+ isShort : isShort
261+ } ) ;
262+
263+ const index = shiftedParts . map ( i => i . type ) . indexOf ( 'timeZoneName' ) ;
264+
265+ if ( index >= 0 ) {
266+ shiftedParts [ index ] = {
267+ type : 'timeZoneName' ,
268+ value : timeZoneName
269+ } ;
270+ }
271+ }
272+
273+ return shiftedParts ;
274+ }
275+ } ) ;
276+ }
277+
213278 Object . defineProperty ( DateTimeFormatPolyfill . prototype , 'resolvedOptions' , {
214279 writable : true ,
215280 configurable : true ,
0 commit comments