Skip to contents

The first and the last day of a range, with a dash between them, such as 7 Apr to 17 May 2025. The first day has its own year only when it differs from that of the last, and a range of one day is that day.

Usage

fmt_range(from, to)

Arguments

from, to

The first and the last day, dates.

Value

A character string.

Examples

rghcard:::fmt_range(as.Date("2025-04-07"), as.Date("2025-05-17"))
#> [1] "7 Apr – 17 May 2025"
rghcard:::fmt_range(as.Date("2025-12-20"), as.Date("2026-01-05"))
#> [1] "20 Dec 2025 – 5 Jan 2026"
rghcard:::fmt_range(as.Date("2026-12-03"), as.Date("2026-12-03"))
#> [1] "3 Dec 2026"