@@ -40,6 +40,10 @@ function isBrowser12hCycle() {
4040 return Boolean ( / \s / . exec ( new Intl . DateTimeFormat ( [ ] , { hour : 'numeric' } ) . format ( 0 ) ) )
4141}
4242
43+ function isHour12 ( hourCycle : Intl . DateTimeFormatOptions [ 'hourCycle' ] ) {
44+ return hourCycle === 'h11' || hourCycle === 'h12'
45+ }
46+
4347const dateObserver = new ( class {
4448 elements : Set < RelativeTimeElement > = new Set ( )
4549 time = Infinity
@@ -155,7 +159,7 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
155159 minute : '2-digit' ,
156160 timeZoneName : 'short' ,
157161 timeZone : this . timeZone ,
158- hour12 : this . hourCycle === 'h12' ,
162+ hour12 : isHour12 ( this . hourCycle ) ,
159163 } ) . format ( date )
160164 }
161165
@@ -230,7 +234,7 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
230234 year : this . year ,
231235 timeZoneName : this . timeZoneName ,
232236 timeZone : this . timeZone ,
233- hour12 : this . hourCycle === 'h12' ,
237+ hour12 : isHour12 ( this . hourCycle ) ,
234238 } )
235239 return `${ this . prefix } ${ formatter . format ( date ) } ` . trim ( )
236240 }
@@ -264,7 +268,7 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor
264268 minute : '2-digit' ,
265269 timeZoneName : 'short' ,
266270 timeZone : this . timeZone ,
267- hour12 : this . hourCycle === 'h12' ,
271+ hour12 : isHour12 ( this . hourCycle ) ,
268272 }
269273
270274 if ( this . #isToday( date ) ) {
0 commit comments