Rocky_Mountain_Vending/.pnpm-store/v10/files/9c/736f33007b24fadb120a8b3d6febae01222770e304e3d3312abafc9a77f4969ad21f16f827ed2b9e428dded04dce7ce2531e39ba6cd40cade9cbd53864f584
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

49 lines
1.5 KiB
Text

"use strict";
exports.milliseconds = milliseconds;
var _index = require("./constants.cjs");
/**
* @name milliseconds
* @category Millisecond Helpers
* @summary
* Returns the number of milliseconds in the specified, years, months, weeks, days, hours, minutes and seconds.
*
* @description
* Returns the number of milliseconds in the specified, years, months, weeks, days, hours, minutes and seconds.
*
* One years equals 365.2425 days according to the formula:
*
* > Leap year occurs every 4 years, except for years that are divisible by 100 and not divisible by 400.
* > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
*
* One month is a year divided by 12.
*
* @param duration - The object with years, months, weeks, days, hours, minutes and seconds to be added.
*
* @returns The milliseconds
*
* @example
* // 1 year in milliseconds
* milliseconds({ years: 1 })
* //=> 31556952000
*
* // 3 months in milliseconds
* milliseconds({ months: 3 })
* //=> 7889238000
*/
function milliseconds({ years, months, weeks, days, hours, minutes, seconds }) {
let totalDays = 0;
if (years) totalDays += years * _index.daysInYear;
if (months) totalDays += months * (_index.daysInYear / 12);
if (weeks) totalDays += weeks * 7;
if (days) totalDays += days;
let totalSeconds = totalDays * 24 * 60 * 60;
if (hours) totalSeconds += hours * 60 * 60;
if (minutes) totalSeconds += minutes * 60;
if (seconds) totalSeconds += seconds;
return Math.trunc(totalSeconds * 1000);
}