Rocky_Mountain_Vending/.pnpm-store/v10/files/17/6f4466031b054b83a77de3d45d2f2f965488bc2f14c0328e45f01f14e90b219901c664278e0c46a1cd6a8816fd105e807bdd4b546b9a8cd20a5982ebf50148
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

61 lines
1.7 KiB
Text

/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview
* @suppress {reportUnknownTypes}
*/
/**
* Generate a filenamePrefix of name_YYYY-MM-DD_HH-MM-SS
* Date/time uses the local timezone, however Node has unreliable ICU
* support, so we must construct a YYYY-MM-DD date format manually. :/
* @param {string} name
* @param {string|undefined} fetchTime
*/
function getFilenamePrefix(name, fetchTime) {
const date = fetchTime ? new Date(fetchTime) : new Date();
const timeStr = date.toLocaleTimeString('en-US', {hour12: false});
const dateParts = date.toLocaleDateString('en-US', {
year: 'numeric', month: '2-digit', day: '2-digit',
}).split('/');
// @ts-expect-error - parts exists
dateParts.unshift(dateParts.pop());
const dateStr = dateParts.join('-');
const filenamePrefix = `${name}_${dateStr}_${timeStr}`;
// replace characters that are unfriendly to filenames
return filenamePrefix.replace(/[/?<>\\:*|"]/g, '-');
}
/**
* Generate a filenamePrefix of hostname_YYYY-MM-DD_HH-MM-SS.
* @param {{finalDisplayedUrl: string, fetchTime: string}} lhr
* @return {string}
*/
function getLhrFilenamePrefix(lhr) {
const hostname = new URL(lhr.finalDisplayedUrl).hostname;
return getFilenamePrefix(hostname, lhr.fetchTime);
}
/**
* Generate a filenamePrefix of name_YYYY-MM-DD_HH-MM-SS.
* @param {{name: string, steps: Array<{lhr: {fetchTime: string}}>}} flowResult
* @return {string}
*/
function getFlowResultFilenamePrefix(flowResult) {
const lhr = flowResult.steps[0].lhr;
const name = flowResult.name.replace(/\s/g, '-');
return getFilenamePrefix(name, lhr.fetchTime);
}
export {
getLhrFilenamePrefix,
getFilenamePrefix,
getFlowResultFilenamePrefix,
};