const https = require('https') const http = require('http') const testNewTimeFormat = async () => { console.log('šŸ” ęø¬č©¦ę–°ēš„ę™‚é–“ę ¼å¼') console.log('=' .repeat(50)) try { // ęø¬č©¦ē•¶å‰ę™‚é–“ę ¼å¼ console.log('\nšŸ“Š ęø¬č©¦ē•¶å‰ę™‚é–“ę ¼å¼:') const now = new Date() const utcTime = now.toISOString() const taiwanTime = now.toLocaleString("zh-TW", { timeZone: "Asia/Taipei" }) console.log(`ē•¶å‰ UTC Ꙃ間: ${utcTime}`) console.log(`ē•¶å‰å°ē£ę™‚é–“: ${taiwanTime}`) // ęø¬č©¦ę™‚é–“č½‰ę› console.log('\nšŸ“Š ęø¬č©¦ę™‚é–“č½‰ę›:') const testDate = new Date(utcTime) const convertedTaiwanTime = testDate.toLocaleString("zh-TW", { timeZone: "Asia/Taipei" }) console.log(`č½‰ę›å¾Œēš„å°ē£ę™‚é–“: ${convertedTaiwanTime}`) // é©—č­‰č½‰ę›ę˜Æå¦ę­£ē¢ŗ const isCorrect = taiwanTime === convertedTaiwanTime console.log(`č½‰ę›ę˜Æå¦ę­£ē¢ŗ: ${isCorrect ? 'āœ…' : 'āŒ'}`) // ęø¬č©¦äøåŒēš„ę™‚é–“ę ¼å¼ console.log('\nšŸ“Š ęø¬č©¦äøåŒę™‚é–“ę ¼å¼:') const formats = [ { name: 'UTC ę ¼å¼ (修正後)', time: now.toISOString() }, { name: 'čˆŠę ¼å¼ (ęœ‰å•é”Œ)', time: now.toISOString().replace('Z', '').replace('T', ' ') } ] formats.forEach(format => { console.log(`\n${format.name}: ${format.time}`) const date = new Date(format.time) const taiwan = date.toLocaleString("zh-TW", { timeZone: "Asia/Taipei" }) console.log(` č½‰ę›ē‚ŗå°ē£ę™‚é–“: ${taiwan}`) }) } catch (error) { console.error('āŒ 測試失敗:', error.message) } finally { console.log('\nāœ… ę–°ę™‚é–“ę ¼å¼ęø¬č©¦å®Œęˆ') } } testNewTimeFormat()