function toMinutes(time) { if (!time && time !== 0) return 0; if (typeof time ===…
- User
function toMinutes(time) { if (!time && time !== 0) return 0; if (typeof time === "number") return Math.round(time); const [h = 0, m = 0] = String(time) .split(":") .map((v) => Number(v || 0)); return (h || 0) * 60 + (m || 0); }
function toHours(mins) { return mins / 60; }
function normalizeDate(dateStr) { if (!dateStr) return ""; try { const d = new Date(dateStr); if (!isNaN(d.getTime())) return d.toISOString().slice(0, 10); } catch { return "Failed to parse date"; } return String(dateStr).slice(0, 10); }
function tryParseMaybeString(val) { if (Array.isArray(val)) return val; if (typeof val === "string") { const trimmed = val.trim(); if (trimmed === "") return []; try { const p = JSON.parse(trimmed); return p; } catch { return trimmed .split(",") .map((s) => s.trim()) .filter(Boolean); } } return val || []; }
function getParamKeys(rule) { return Object.keys(rule) .filter((k) => /^param\d+$/.test(k)) .sort((a, b) => { const ai = Number(a.replace("param", "")); const bi = Number(b.replace("param", "")); return ai - bi; }); }
function getParamsArray(rule) { if (!rule) return []; const keys = getParamKeys(rule); return keys.map((k) => (k in rule ? rule[k] : null)); }
function firstNumericParam(rule) { const params = getParamsArray(rule); for (const v of params) { if (v !== null && v !== undefined && String(v).trim() !== "") { const n = Number(v); if (!Number.isNaN(n)) return n; return v; } } return null; }
function firstNonEmptyParam(rule) { const params = getParamsArray(rule); for (const v of params) { if (v !== null && v !== undefined && String(v).trim() !== "") return v; } return null; }
function getRuleByNumber(rules, ruleNumber) { if (!Array.isArray(rules)) return null; const id = String(ruleNumber - 1); return ( rules.find((r) => String(r.ruleId) === id && Number(r.ruleStatus) === 1) || null ); }
function roundOvertime(minutes, minUnit) { const unit = Number(minUnit || 0); if (!unit) return minutes; if (minutes <= 0) return 0; if (minutes < unit) return 0; const rem = minutes % unit; return rem === 0 ? minutes : minutes + (unit - rem); }
// Enhanced function to parse otherSalary function parseOtherSalary(otherSalary) { if (!otherSalary) return 0;
// If it's a number if (typeof otherSalary === "number") return otherSalary;
// If it's an empty string if (typeof otherSalary === "string" && otherSalary.trim() === "") return 0;
// If it's a string number if (typeof otherSalary === "string") { const num = Number(otherSalary); if (!isNaN(num)) return num; }
// If it's an array of salary objects if (Array.isArray(otherSalary)) { return otherSalary.reduce((total, item) => { if (item && typeof item === "object" && item.amount) { return total + Number(item.amount || 0); } return total; }, 0); }
return 0; }
// Enhanced function to parse Rule 1 (shifts and overtime) function parseRule1(rule1) { if (!rule1) return null;
- Assistant
- User
- Assistant
- User
it's give this output { "normal": 0, "weekend": 0, "holiday": 0 }. listen i tell you how to find rule value if ruleId: 0 that mane it's a rule 1 value . if ruleId: 9 it's mane it's a rule 10 value . and ignore rule 24 becase it's rule 25 is upcomming rule . now tell me why it's give output normal ,weekend,holiday overtime 0 .
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.