CARVIEW |
Select Language
HTTP/2 200
date: Tue, 22 Jul 2025 18:03:47 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"f6995ed3b1f389ce3ecb8695defd3e6d"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=fRbmI1byhBZa8Y6FiIsmicbMydlPVjlYkbPGI6%2BYqDRvY7CUY5LsvgOX4zwbhrWifdBG%2FZ1IJq74lXWkeVy1su1R4uQWDsr4eqEMscA839j6SVCfH9C1jG7bfh8hSWl9rZgaf5Aslblk1nZ1UcqbSAwrr0gUiS03ajwR1APqLSekoDKXygx8BKsJNkxIA1E29I7NIZdWAVO73MBW5ABservzne9Y85piSv1JFroRXfq%2Fhk%2FNXuxY9xN6oQGIcfD832vPDxWHJABYjc3gTzCaBA%3D%3D--EwIC5VxZzyuYv9Jg--Je8g0oyTNCjJX58lEHgezg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1933661137.1753207426; Path=/; Domain=github.com; Expires=Wed, 22 Jul 2026 18:03:46 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 22 Jul 2026 18:03:46 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9AD4:17EAA:96BC:B8B4:687FD282
Date Pattern helpers · shuckster/match-iz Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 2
Date Pattern helpers
Conan edited this page Mar 29, 2023
·
11 revisions
The following date matchers are available from match-iz/dates
(or directly from the matchiz
and matchiz.utc
global variables if you're using the browser-build.)
Time | Days of the week | Weeks of the month | Months | Years |
---|---|---|---|---|
isHour(0..23) |
isDay(-31..31) |
nthSun(-5..5) |
isMonth(1..12) |
isYear(n) |
isMinute(0..59) |
isDayOfWeek(0..6) |
nthMon(-5..5) |
- | isWeekNumber(1..52) |
isSecond(0..59) |
- | nthTue(-5..5) |
isJan |
isLeapYear |
- | isSun |
nthWed(-5..5) |
isFeb |
- |
isAM |
isMon |
nthThu(-5..5) |
isMar |
- |
isPM |
isTue |
nthFri(-5..5) |
isApr |
- |
isMorning |
isWed |
nthSat(-5..5) |
isMay |
- |
isAfternoon |
isThu |
- | isJun |
- |
isEvening |
isFri |
- | isJul |
- |
- | isSat |
- | isAug |
- |
isBefore(date) |
- | - | isSep |
- |
isAfter(date) |
- | - | isOct |
- |
- | - | - | isNov |
- |
inThePast(n,timeFrame) |
- | - | isDec |
- |
inTheNext(n,timeFrame) |
- | - | - | - |
inTheFuture(n,timeFrame) |
- | - | - | - |
- | - | - | - | - |
isTime(ms) |
- | - | - | - |
- | - | - | - | - |
inDay/s(Date) |
- | - | - | - |
inMonth/s(Date) |
- | - | - | - |
inYear/s(Date) |
- | - | - | - |
import { isSun, ...etc } from 'match-iz/dates'
import { isSun, ...etc } from 'match-iz/dates/utc'
Matchers | Meaning |
---|---|
isTime |
ms since Unix epoch |
match(new Date())(
when(isTime(0), '1st of January 1970'),
when(isTime(inRange(+new Date(1990), +new Date(2020))), '30 year span'),
when(
isTime(ms => ms < 0),
'Before the 1st of January 1970'
),
)
Matchers | Meaning |
---|---|
inDay / inMonth / inYear / inDays / inMonths / inYears
|
falls within the specified day(s), month(s), or year(s) |
let date = new Date(2021, 0, 1, 12, 0, 0)
match(date)(
when(inDay(new Date(2021, 0, 1)), 'January 1st 2021'),
when(inDay(new Date(2021, 0, 2)), 'January 2nd 2021')
)
Use a 1-based month index by passing an array:
let date = new Date(2021, 0, 1, 12, 0, 0)
match(date)(
when(inDay([2021, 1, 1]), 'January 1st 2021'),
when(inDay([2021, 1, 2]), 'January 2nd 2021')
)
The plural helpers accept arrays of date-objects and/or 1-based month-index arrays:
let date = new Date(2021, 0, 1, 12, 0, 0)
match(date)(
when(inDays([[2021, 1, 1], new Date(2021, 0, 2)]), 'January 1st or 2nd 2021')
)
Matchers | Meaning |
---|---|
inThePast / inTheNext / inTheFuture
|
in a past or future time-frame (inTheNext + inTheFuture are the same functions) |
match(new Date())(
when(inThePast(1, 'day'), 'Pretty recent'),
when(inThePast(2, 'weeks'), 'Last fortnight'),
when(inTheNext(24, 'hours'), 'Too soon'),
when(inTheFuture(), "It's coming"),
when(inThePast(), 'That was quick')
)
// Available time-frames:
// 'ms', 'seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years'
Matchers | Meaning |
---|---|
isHour / isMinute / isSecond / isAM / isPM / isMorning / isAfternoon / isEvening
|
the time of day |
const isMidday = allOf(isHour(12), isPM)
match(new Date())(
when(isHour(0), 'around midnight'),
when(isHour(inRange(12, 14)), 'lunchtime'),
when(allOf(isHour(17), isMinute(0), isSecond(0)), 'clock-off'),
when(isAM, 'morning'),
when(isPM, 'afternoon'),
when(isAfternoon, 'afternoon'),
when(isEvening, 'evening, 6pm-midnight'),
when(isMidday, "It's midday")
)
Matchers | Meaning |
---|---|
isBefore / isAfter
|
before/after a date |
match(new Date())(
when(isBefore([2001, 1, 1]), 'Before midnight January 1st, 2001'),
when(isAfter([1970, 5]), 'After May 1970 (ie; June onwards)'),
when(isBefore([1999]), 'Before 1999 (ie; up to and including 1998)'),
when(isAfter(new Date(2001, 0, 1)), 'After midnight January 1st, 2001')
)
Matchers | Meaning |
---|---|
isDay / isDayOfWeek / isSun / isMon / isTue / isWed / isThu / isFri / isSat
|
is that particular day of the month, week, or weekday. isDay accepts negative numbers to work backwards from the end of the month |
match(new Date())(
when(isDay(1), 'First day of the month'),
when(isDay(-1), 'Last day of the month'),
when(isMon, "I don't like them"),
when(anyOf(isSat, isSun), 'Weekend!'),
when(isDayOfWeek(0), 'Sunday'),
when(isDayOfWeek(6), 'Saturday'),
otherwise('Back to the grind')
)
Matchers | Meaning |
---|---|
nthSun / nthMon / nthTue / nthWed / nthThu / nthFri / nthSat
|
the nth *day of the month. Negatives allowed to search from the end |
match(new Date())(
when(nthSun(2), 'Second Sunday of the month'),
when(nthFri(-1), 'Last Friday of the month'),
when(anyOf(nthMon(1), nthFri(1)), '1st Monday/Friday of the month')
)
Matchers | Meaning |
---|---|
isMonth / isJan / isFeb / isMar / isApr / isMay / isJun / isJul / isAug / isSep / isOct / isNov / isDec
|
is that particular month |
match(new Date())(
when(isJan, "It's January"),
when(anyOf(isFeb, isMar), 'Is it February or March?'),
when(allOf(isDec, isDay(24)), 'Christmas already?'),
when(isMonth(1), "It's January, of course"),
when(
isMonth(x => [4, 5].includes(x)),
dateObj => `April or May: ${dateObj.toString()}`
)
)
Matchers | Meaning |
---|---|
isYear / isWeekNumber / isLeapYear
|
is the specified year, week-number, or tests if the year is a leap-year |
match(new Date())(
when(isYear(2015), 'Flying cars and skateboards'),
when(isLeapYear, 'Leap year'),
when(
isYear(x => x % 2 === 0),
dateObj => `An even numbered year: ${dateObj.toString()}`
),
when(allOf(isYear(2020), isMar), 'Better forgotten'),
when(isWeekNumber(1), 'First week of the year'),
when(isWeekNumber(52), 'Last week of the year'),
when(not(isWeekNumber(13)), () => {
return 'Not the 13th week of the year'
})
)
Clone this wiki locally
You can’t perform that action at this time.