Skip to content

Conversation

@chhoumann
Copy link
Owner

@chhoumann chhoumann commented Nov 24, 2025

Summary

  • Rewrote formatDate using a proper token-based parser instead of sequential .replace() calls
  • The old approach corrupted month/weekday names (e.g., formatDate(date, 'MMMM') returned "Marc10" instead of "March" because 'h' was replaced by the hour value)
  • New implementation uses single-pass regex tokenizer that matches tokens by priority (longest first)
  • Added support for Moment.js-style escape syntax [...] for literal text

Test plan

  • Build passes
  • All 131 tests pass (72 new tests for formatDate)
  • Verify formatDate(new Date('2024-03-01T10:00:00'), 'MMMM') returns "March" (not "Marc10")
  • Verify all 12 months work correctly at every hour (0-23)
  • Verify all 7 weekdays work correctly at every minute interval
  • Verify ordinal suffixes (1st, 2nd, 3rd, etc.) are not corrupted
  • Verify escape syntax [literal text] works correctly

New test coverage

  • All token types (year, month, day, weekday, time, AM/PM)
  • Sequential replacement corruption scenarios
  • Escape syntax edge cases
  • Stress tests: 288 month/hour combinations, 42 weekday/minute combinations
  • Token isolation (M doesn't affect MMMM, h doesn't affect HH, etc.)

@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
podnotes Ignored Ignored Preview Nov 24, 2025 9:25pm

Rewrote formatDate using a proper token-based parser instead of sequential
.replace() calls. The old approach corrupted month/weekday names (e.g.,
"March" became "Marc10" because 'h' was replaced by the hour value).

Changes:
- Use single-pass regex tokenizer that matches tokens by priority (longest first)
- Add support for Moment.js-style escape syntax [...] for literal text
- Non-token characters pass through unchanged
- Add comprehensive test suite with 72 tests covering:
  - All token types (year, month, day, weekday, time, AM/PM)
  - Sequential replacement corruption scenarios
  - Escape syntax edge cases
  - Stress tests across all month/hour/minute combinations
@chhoumann chhoumann force-pushed the fix/formatDate-sequential-replacement-corruption branch from 958ecf5 to c933b40 Compare November 24, 2025 21:25
@chhoumann chhoumann merged commit 3b2dcac into master Nov 24, 2025
3 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 24, 2025
# [2.15.0](2.14.3...2.15.0) (2025-11-24)

### Bug Fixes

* add setter for playbackRate binding to prevent runtime error ([992c0cc](992c0cc))
* artwork image now fills full container size ([1407209](1407209))
* detach leaves on plugin unload to prevent duplicate views ([692279d](692279d))
* **FeedParser:** fix metadata handling and add tests ([a30eca1](a30eca1))
* fix crash when navigating away from Latest Episodes during fetch ([9e8cd18](9e8cd18))
* **formatDate:** rewrite with token parser to prevent corruption ([#157](#157)) ([3b2dcac](3b2dcac))
* guard obsidian inputs from feedback loops ([#154](#154)) ([2d8b5c5](2d8b5c5))
* mount views with svelte api ([#134](#134)) ([f2d6e80](f2d6e80))
* move chapter fetching from reactive block to subscription ([9d67c41](9d67c41))
* performance overhaul to prevent crashes ([30a5a0a](30a5a0a))
* persist hide-played toggle ([#144](#144)) ([732f094](732f094))
* playlist card sizing to properly contain icon and count text ([ff18fbc](ff18fbc))
* podcast grid now scrolls properly ([2965af2](2965af2))
* **TranscriptionService:** fix bugs and add tests ([fb20e25](fb20e25))
* use get() for store access inside async functions ([8a20a33](8a20a33))

### Features

* add podcast chapter support ([d10eeb7](d10eeb7))
* add timestamp offset setting ([#131](#131)) ([46c4d4b](46c4d4b))
* style improvements ([f566bc9](f566bc9))
@github-actions
Copy link

🎉 This PR is included in version 2.15.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants