release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of [CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md) for the full list. Highlights: client proofing links (#683), custom content pages (#738), asset picker search (#740), concurrent-edit detection (#742), env-locked settings (#739), an accessibility baseline (#741), three security fixes with advisories (#737, #755, #759), and a pre-release quality pass (#780–#797). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: ralksta <ralksta@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Ralf <rohlenbo79@gmail.com> Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com> Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com> Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
This commit is contained in:
49
lib/journalDate.ts
Normal file
49
lib/journalDate.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Display form of a journal entry's `date:` frontmatter. Client-safe (no `fs`),
|
||||
* shared by the /journal index and the entry header so both show the same thing.
|
||||
*
|
||||
* The value is typed by hand, so it is read as a calendar date, not an instant:
|
||||
*
|
||||
* - `2026-03-15` (optionally followed by a time) is formatted in UTC. `new Date()`
|
||||
* reads a date-only ISO string as UTC midnight, and formatting that in the
|
||||
* server's or browser's timezone showed Mar 14 west of Greenwich.
|
||||
* - `2026-03` shows month and year — `new Date('2026-03')` invented the 1st.
|
||||
* - Anything else (`15.03.2026`, `March 2026`, `Spring 2026`, an impossible
|
||||
* `2026-02-30`) is shown as written instead of "Invalid Date" or a guessed day.
|
||||
*/
|
||||
const DAY = /^(\d{4})-(\d{2})-(\d{2})(?=$|[T\s])/;
|
||||
const MONTH = /^(\d{4})-(\d{2})$/;
|
||||
|
||||
export function formatJournalDate(raw: string | undefined, locale: string): string | null {
|
||||
const value = raw?.trim();
|
||||
if (!value) return null;
|
||||
|
||||
const day = DAY.exec(value);
|
||||
if (day) {
|
||||
const [y, m, d] = [Number(day[1]), Number(day[2]), Number(day[3])];
|
||||
const date = new Date(Date.UTC(y, m - 1, d));
|
||||
// Date.UTC rolls 2026-02-30 over into March; refuse instead of moving it.
|
||||
if (date.getUTCFullYear() !== y || date.getUTCMonth() !== m - 1 || date.getUTCDate() !== d) {
|
||||
return value;
|
||||
}
|
||||
return date.toLocaleDateString(locale, {
|
||||
timeZone: 'UTC',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
const month = MONTH.exec(value);
|
||||
if (month) {
|
||||
const [y, m] = [Number(month[1]), Number(month[2])];
|
||||
if (m < 1 || m > 12) return value;
|
||||
return new Date(Date.UTC(y, m - 1, 1)).toLocaleDateString(locale, {
|
||||
timeZone: 'UTC',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
Reference in New Issue
Block a user