Complete workout recording baseline and project context

This commit is contained in:
rob
2026-11-04 21:41:17 +00:00
parent e86a2e7850
commit 669bfc3910
29 changed files with 3288 additions and 297 deletions
+76
View File
@@ -0,0 +1,76 @@
import { initialRoutine } from './data/index.js'
const weekdayKeys = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
export function localCalendarDate(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 12)
}
export function addCalendarDays(date, days) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days, 12)
}
export function startOfWeek(date) {
return addCalendarDays(date, -((date.getDay() + 6) % 7))
}
export function localDateKey(date) {
const pad = (value) => String(value).padStart(2, '0')
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`
}
export function routineForDate(date) {
return initialRoutine.days[weekdayKeys[date.getDay()]]
}
function rangeLabel(range) {
return range.min === range.max ? String(range.min) : `${range.min}–${range.max}`
}
function durationLabel(range) {
if (range.min % 60 === 0 && range.max % 60 === 0) {
return `${rangeLabel({ min: range.min / 60, max: range.max / 60 })} min`
}
return `${rangeLabel(range)} sec`
}
export function prescriptionLabel(prescription) {
const per = prescription.per ? ` per ${prescription.per}` : ''
switch (prescription.kind) {
case 'emom':
return `${prescription.rounds} min EMOM · ${rangeLabel(prescription.repsPerRound)} reps each minute`
case 'repetitions':
return prescription.sets
? `${rangeLabel(prescription.sets)} × ${rangeLabel(prescription.reps)} reps${per}`
: `${rangeLabel(prescription.reps)} ${prescription.tempo || ''} reps${per}`.replace(/\s+/g, ' ').trim()
case 'timed-sets':
return prescription.durationSec
? `${rangeLabel(prescription.sets)} × ${durationLabel(prescription.durationSec)}${per}`
: `${rangeLabel(prescription.sets)} sets · duration not specified`
case 'timed-hold':
return `${durationLabel(prescription.durationSec)}${per}`
case 'isometric-hold':
return `Hold${per}`
case 'hanging-practice':
return `Goal: ${durationLabel({ min: prescription.goalDurationSec, max: prescription.goalDurationSec })}`
default:
return ''
}
}
export function restLabel(rest) {
if (!rest) return null
if (rest.kind === 'remainder-of-interval') return 'Rest: remainder of each minute'
if (rest.kind === 'approximate') return `Rest: about ${durationLabel({ min: rest.seconds, max: rest.seconds })}`
return `Rest: ${durationLabel(rest.seconds)}`
}
export function loadLabel(load) {
if (!load) return null
if (load.bodyweightOnly) return 'Bodyweight only'
const parts = []
if ('vestKg' in load) parts.push(load.vestKg === null ? 'Vest load not specified' : `${load.vestKg} kg vest`)
if ('dumbbellKg' in load || 'dumbbellKgEach' in load) parts.push('Dumbbell load not specified')
if ('ezBarTotalKg' in load) parts.push('EZ-bar load not specified')
return parts.join(' · ')
}