@@ -28,8 +28,11 @@ const createFixture = async content => {
2828 return root ;
2929} ;
3030
31- const runFixture = root =>
32- execFileAsync ( process . execPath , [ 'scripts/data/blog.mjs' ] , { cwd : root } ) ;
31+ const runFixture = ( root , timeZone = 'UTC' ) =>
32+ execFileAsync ( process . execPath , [ 'scripts/data/blog.mjs' ] , {
33+ cwd : root ,
34+ env : { ...process . env , TZ : timeZone } ,
35+ } ) ;
3336
3437test ( 'generates blog data for valid dates' , async t => {
3538 const root = await createFixture ( "---\ndate: '2026-09-22'\n---\n# Test\n" ) ;
@@ -43,6 +46,27 @@ test('generates blog data for valid dates', async t => {
4346 assert . equal ( posts [ 0 ] . date , '2026-09-22T00:00:00.000Z' ) ;
4447} ) ;
4548
49+ test ( 'normalizes offset-less quoted date-times as UTC' , async t => {
50+ const root = await createFixture (
51+ "---\ndate: '2026-09-22 10:00'\n---\n# Test\n"
52+ ) ;
53+ t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
54+
55+ const dates = [ ] ;
56+ for ( const timeZone of [ 'UTC' , 'America/Los_Angeles' ] ) {
57+ await runFixture ( root , timeZone ) ;
58+ const posts = JSON . parse (
59+ await readFile ( join ( root , 'generated' , 'blog.json' ) , 'utf8' )
60+ ) ;
61+ dates . push ( posts [ 0 ] . date ) ;
62+ }
63+
64+ assert . deepEqual ( dates , [
65+ '2026-09-22T10:00:00.000Z' ,
66+ '2026-09-22T10:00:00.000Z' ,
67+ ] ) ;
68+ } ) ;
69+
4670test ( 'reports the file for an invalid blog date' , async t => {
4771 const root = await createFixture ( '---\ndate: not-a-date\n---\n# Test\n' ) ;
4872 t . after ( ( ) => rm ( root , { recursive : true , force : true } ) ) ;
0 commit comments