Rocky_Mountain_Vending/.pnpm-store/v10/files/16/d576eb2fafdbca7fbf7faebb5d1ca134aae13c8a62d8b7fba8ed6c69b44c0acaa418971b0f40070861d63860ebfb048798562441036c91d9899398fd1f0f1a
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

95 lines
2.3 KiB
Text

import { setDay } from "../../../setDay.js";
import { Parser } from "../Parser.js";
import { mapValue, parseNDigits } from "../utils.js";
// Local day of week
export class LocalDayParser extends Parser {
priority = 90;
parse(dateString, token, match, options) {
const valueCallback = (value) => {
// We want here floor instead of trunc, so we get -7 for value 0 instead of 0
const wholeWeekDays = Math.floor((value - 1) / 7) * 7;
return ((value + options.weekStartsOn + 6) % 7) + wholeWeekDays;
};
switch (token) {
// 3
case "e":
case "ee": // 03
return mapValue(parseNDigits(token.length, dateString), valueCallback);
// 3rd
case "eo":
return mapValue(
match.ordinalNumber(dateString, {
unit: "day",
}),
valueCallback,
);
// Tue
case "eee":
return (
match.day(dateString, {
width: "abbreviated",
context: "formatting",
}) ||
match.day(dateString, { width: "short", context: "formatting" }) ||
match.day(dateString, { width: "narrow", context: "formatting" })
);
// T
case "eeeee":
return match.day(dateString, {
width: "narrow",
context: "formatting",
});
// Tu
case "eeeeee":
return (
match.day(dateString, { width: "short", context: "formatting" }) ||
match.day(dateString, { width: "narrow", context: "formatting" })
);
// Tuesday
case "eeee":
default:
return (
match.day(dateString, { width: "wide", context: "formatting" }) ||
match.day(dateString, {
width: "abbreviated",
context: "formatting",
}) ||
match.day(dateString, { width: "short", context: "formatting" }) ||
match.day(dateString, { width: "narrow", context: "formatting" })
);
}
}
validate(_date, value) {
return value >= 0 && value <= 6;
}
set(date, _flags, value, options) {
date = setDay(date, value, options);
date.setHours(0, 0, 0, 0);
return date;
}
incompatibleTokens = [
"y",
"R",
"u",
"q",
"Q",
"M",
"L",
"I",
"d",
"D",
"E",
"i",
"c",
"t",
"T",
];
}