fix: keep birthdays and show Shamsi dates
Imported customers keep their birthday, and assistant text plus remaining calendars use the Jalali date. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,9 @@ import assert from 'node:assert/strict';
|
||||
import {
|
||||
addJalaliMonths,
|
||||
endOfJalaliMonth,
|
||||
formatTehranJalali,
|
||||
jalaliMonthName,
|
||||
rewriteGregorianDates,
|
||||
toGregorian,
|
||||
toJalali,
|
||||
} from '../src/common/jalali';
|
||||
@@ -102,3 +104,21 @@ describe('یادآور چک', () => {
|
||||
assert.ok(!isDueInDays(new Date('2026-10-12T12:00:00Z'), 3, now));
|
||||
});
|
||||
});
|
||||
|
||||
describe('بازنویسی تاریخ میلادی در متن', () => {
|
||||
const now = new Date('2026-10-13T08:00:00Z');
|
||||
|
||||
it('۲۱ سپتامبر را شمسی میکند و مهر را دست نمیزند', () => {
|
||||
const out = rewriteGregorianDates('آخرین خرید در تاریخ 21 سپتامبر انجام شده', now);
|
||||
assert.equal(out.includes('سپتامبر'), false);
|
||||
assert.match(out, /۱۴۰۵\/۰۶\/۳۰/);
|
||||
assert.equal(rewriteGregorianDates('مهلت تا 21 مهر ۱۴۰۵', now), 'مهلت تا 21 مهر ۱۴۰۵');
|
||||
assert.equal(rewriteGregorianDates('میشود 21 بار', now), 'میشود 21 بار');
|
||||
});
|
||||
|
||||
it('September و تاریخ عددی میلادی را شمسی میکند', () => {
|
||||
assert.match(rewriteGregorianDates('bought on September 21, 2025', now), /۱۴۰۴\/۰۶\/۳۰/);
|
||||
assert.equal(rewriteGregorianDates('due 2026-09-21', now), 'due ۱۴۰۵/۰۶/۳۰');
|
||||
assert.equal(formatTehranJalali(new Date('2026-09-21T08:00:00Z')), '۱۴۰۵/۰۶/۳۰');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user