@@ -41,11 +41,12 @@ describe('InternalTime', () => {
4141 const defs = time . getVariableDefinitions ( )
4242 const names = defs . map ( ( d ) => d . name )
4343
44- expect ( defs ) . toHaveLength ( 17 )
44+ expect ( defs ) . toHaveLength ( 18 )
4545 expect ( names ) . toEqual ( [
4646 'date_iso' ,
4747 'date_y' ,
4848 'date_m' ,
49+ 'date_monthname' ,
4950 'date_d' ,
5051 'date_dow' ,
5152 'date_weekday' ,
@@ -182,6 +183,28 @@ describe('InternalTime', () => {
182183 } )
183184 } )
184185
186+ test ( 'emits the month name in the configured timezone' , ( ) => {
187+ // Just after midnight UTC on 1 July: still June in New York, already July in Tokyo
188+ const now = new Date ( '2024-07-01T01:30:00Z' )
189+ const config = { timezone : 'America/New_York' }
190+
191+ vi . setSystemTime ( now )
192+ const time = new InternalTime ( mockUserConfig ( config ) )
193+ const setVariables = vi . fn < ( values : VariableValues ) => void > ( )
194+ time . on ( 'setVariables' , setVariables )
195+
196+ // Compare against the host locale's names, so the assertion is locale-independent
197+ const monthName = ( m : number ) =>
198+ new Date ( Date . UTC ( 2024 , m , 15 ) ) . toLocaleString ( undefined , { month : 'long' , timeZone : 'UTC' } )
199+
200+ time . updateVariables ( )
201+ expect ( lastValues ( setVariables ) . date_monthname ) . toBe ( monthName ( 5 ) )
202+
203+ config . timezone = 'Asia/Tokyo'
204+ time . updateVariables ( )
205+ expect ( lastValues ( setVariables ) . date_monthname ) . toBe ( monthName ( 6 ) )
206+ } )
207+
185208 test ( 'exposes the resolved system timezone when none is configured' , ( ) => {
186209 const { time, setVariables } = createTime ( new Date ( '2024-06-15T01:30:00Z' ) )
187210 time . updateVariables ( )
0 commit comments