Skip to content

Add daybefore date formatter#1292

Merged
mstijak merged 1 commit into
masterfrom
feature/1290-daybefore-formatter
May 18, 2026
Merged

Add daybefore date formatter#1292
mstijak merged 1 commit into
masterfrom
feature/1290-daybefore-formatter

Conversation

@mstijak
Copy link
Copy Markdown
Member

@mstijak mstijak commented May 18, 2026

Summary

Adds a daybefore formatter that renders a date shifted back by one calendar day, using the same pattern argument as datetime.

It's handy for displaying the exclusive end of a date range as an inclusive value — e.g. a period running from 2020-01-01 up to (but not including) 2021-01-01 can be shown as Dec 2020.

daybefore;MMM yyyy   2021-01-01  ->  "Dec 2020"
daybefore;yyyyMMdd   2021-01-01  ->  "12/31/2020"

Changes

  • util/date/dayBefore.ts (new) — dayBefore(date: Date): Date helper returning the previous calendar day (no mutation; accepts an already-parsed Date).
  • util/Format.ts — basic dayBefore formatter + daybefore alias, mirroring basic datetime.
  • ui/Format.ts — culture-sensitive dayBefore/daybefore formatter, same pattern argument and "yyyyMd hhmm" default as datetime.
  • util/Format.spec.ts — tests for the day shift and month/year boundary crossing.
  • homedocs/.../formatting.mdx — a "Day-Before Format" docs subsection.

Testing

  • Format test suite: 13 passing (including 2 new daybefore cases).
  • yarn check-types: clean.

Closes #1290

Adds a `daybefore` formatter that renders a date shifted back by one
calendar day, using the same pattern argument as `datetime`. Useful for
displaying the exclusive end of a date range as an inclusive value, e.g.
a period ending at 2021-01-01 shown as "Dec 2020".

Registered as `dayBefore` with a `daybefore` alias in both the basic
(util/Format.ts) and culture-sensitive (ui/Format.ts) formatter sets.

Closes #1290
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for cxjs-docs ready!

Name Link
🔨 Latest commit 2530d53
🔍 Latest deploy log https://app.netlify.com/projects/cxjs-docs/deploys/6a0b204bdc5b42000823c1b6
😎 Deploy Preview https://deploy-preview-1292--cxjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mstijak mstijak merged commit b5cf3a6 into master May 18, 2026
5 of 6 checks passed
@mstijak mstijak deleted the feature/1290-daybefore-formatter branch May 18, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a daybefore formatter (date minus one day)

1 participant