mirror of https://github.com/langgenius/dify.git
Critical regression fix for convertTimezoneToOffsetStr:
Issues Fixed:
- Previous regex /^([+-]?\d{1,2}):00/ only matched :00 offsets
- This caused half-hour offsets (e.g., India +05:30) to return UTC+0
- Even if matched, parseInt only parsed hours, losing minute info
Changes:
- Update regex to /^([+-]?\d{1,2}):(\d{2})/ to match all offset formats
- Parse both hours and minutes separately
- Output format: "UTC+5:30" for non-zero minutes, "UTC+8" for whole hours
- Preserve leading zeros in minute part (e.g., "UTC+5:30" not "UTC+5:3")
Test Coverage:
- Added 8 comprehensive tests covering:
* Default/invalid timezone handling
* Whole hour offsets (positive/negative)
* Zero offset (UTC)
* Half-hour offsets (India +5:30, Australia +9:30)
* 45-minute offset (Chatham +12:45)
* Leading zero preservation in minutes
All 14 tests passing. Verified with timezone.json entries at lines 967, 1135, 1251.
|
||
|---|---|---|
| .. | ||
| (commonLayout) | ||
| (shareLayout) | ||
| account | ||
| activate | ||
| components | ||
| dev-preview | ||
| education-apply | ||
| forgot-password | ||
| init | ||
| install | ||
| oauth-callback | ||
| repos/[owner]/[repo]/releases | ||
| reset-password | ||
| signin | ||
| signup | ||
| styles | ||
| layout.tsx | ||
| page.module.css | ||
| page.tsx | ||
| routePrefixHandle.tsx | ||