File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,8 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
198198 month : this . month ,
199199 year : this . year ,
200200 timeZoneName : this . timeZoneName ,
201+ dateStyle : this . dateStyle ,
202+ timeStyle : this . timeStyle ,
201203 } )
202204 return `${ this . prefix } ${ formatter . format ( date ) } ` . trim ( )
203205 }
@@ -326,6 +328,38 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
326328 this . setAttribute ( 'time-zone-name' , value || '' )
327329 }
328330
331+ get dateStyle ( ) {
332+ const dateStyle = this . getAttribute ( 'date-style' )
333+
334+ if ( dateStyle === 'short' || dateStyle === 'long' || dateStyle === 'full' || dateStyle === 'medium' ) {
335+ return dateStyle
336+ }
337+ }
338+
339+ set dateStyle ( value : 'short' | 'long' | 'full' | 'medium' | undefined ) {
340+ if ( value ) {
341+ this . setAttribute ( 'date-style' , value )
342+ } else {
343+ this . removeAttribute ( 'date-style' )
344+ }
345+ }
346+
347+ get timeStyle ( ) {
348+ const timeStyle = this . getAttribute ( 'time-style' )
349+
350+ if ( timeStyle === 'short' || timeStyle === 'long' || timeStyle === 'full' || timeStyle === 'medium' ) {
351+ return timeStyle
352+ }
353+ }
354+
355+ set timeStyle ( value : 'short' | 'long' | 'full' | 'medium' | undefined ) {
356+ if ( value ) {
357+ this . setAttribute ( 'time-style' , value )
358+ } else {
359+ this . removeAttribute ( 'time-style' )
360+ }
361+ }
362+
329363 /** @deprecated */
330364 get prefix ( ) : string {
331365 return this . getAttribute ( 'prefix' ) ?? ( this . format === 'datetime' ? '' : 'on' )
You can’t perform that action at this time.
0 commit comments