Swine Gestation Calculator

#swine-gestation-calculator { max-width: 600px; margin: 20px auto; padding: 15px; background: #fff; border-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-family: -apple-system, BlinkMacSystemFont, ‘Arial’, sans-serif; color: #333; box-sizing: border-box; } h2 { text-align: center; margin: 0 0 15px; font-size: 1.4rem; line-height: 1.2; color: #333; } p { text-align: center; color: #666; font-size: 14px; margin-bottom: 15px; } .form-group { margin-bottom: 15px; position: relative; } label { display: block; margin-bottom: 5px; font-size: 0.9rem; font-weight: 600; } input[type=”date”], input[type=”number”] { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 3px; font-size: 0.9rem; box-sizing: border-box; } input:focus { border-color: #0073aa; outline: none; } .tooltip { position: relative; display: inline-block; margin-left: 5px; } .tooltip .tooltip-text { visibility: hidden; width: 180px; background: #333; color: #fff; text-align: center; border-radius: 3px; padding: 5px; position: absolute; z-index: 10; bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; font-size: 0.75rem; } .tooltip:hover .tooltip-text { visibility: visible; opacity: 1; } .button-group { display: flex; gap: 10px; justify-content: center; margin-top: 15px; } button { padding: 8px 16px; border: none; border-radius: 3px; cursor: pointer; font-size: 0.9rem; background: #0073aa; color: #fff; } button:hover { background: #005177; } #reset-btn { background: #6c757d; } #reset-btn:hover { background: #5a6268; } #copy-btn { background: #28a745; } #copy-btn:hover { background: #218838; } #result { margin-top: 15px; padding: 10px; border-radius: 3px; font-size: 0.9rem; line-height: 1.4; min-height: 20px; } #result.success { background: #e6f4ea; border: 1px solid #28a745; } #result.error { background: #f8d7da; border: 1px solid #dc3545; } .progress-bar { width: 100%; background: #f0f0f0; border-radius: 3px; height: 20px; margin-top: 10px; overflow: hidden; } .progress-bar-fill { height: 100%; background: #28a745; transition: width 0.3s ease; } .timeline { margin-top: 10px; font-size: 0.85rem; } .timeline div { margin: 5px 0; } noscript { display: block; color: #dc3545; text-align: center; margin-top: 10px; font-size: 0.9rem; } @media (max-width: 600px) { #swine-gestation-calculator { margin: 10px; padding: 10px; } h2 { font-size: 1.2rem; } .button-group { flex-direction: column; } button { width: 100%; } }

Swine Gestation Calculator

Estimate your sow’s farrowing date and track pregnancy stages.

JavaScript is disabled. Please enable it to use the calculator. (function() { if (!document.getElementById(‘swine-gestation-calculator’)) return; const form = document.getElementById(‘calc-form’); const breedingDateInput = document.getElementById(‘breeding-date’); const gestationPeriodInput = document.getElementById(‘gestation-period’); const resultDiv = document.getElementById(‘result’); function formatDate(date) { return date.toLocaleDateString(‘en-US’, { weekday: ‘long’, year: ‘numeric’, month: ‘long’, day: ‘numeric’ }); } function calculate() { resultDiv.className = ”; resultDiv.innerHTML = ”; try { const breedingDateStr = breedingDateInput.value; const gestationDays = parseInt(gestationPeriodInput.value); if (!breedingDateStr) { throw new Error(‘Breeding date is required.’); } if (isNaN(gestationDays) || gestationDays 120) { throw new Error(‘Gestation period must be between 112 and 120 days.’); } const breedingDate = new Date(breedingDateStr); if (isNaN(breedingDate.getTime())) { throw new Error(‘Invalid breeding date.’); } const dueDate = new Date(breedingDate); dueDate.setDate(breedingDate.getDate() + gestationDays); const minDueDate = new Date(breedingDate); minDueDate.setDate(breedingDate.getDate() + 112); const maxDueDate = new Date(breedingDate); maxDueDate.setDate(breedingDate.getDate() + 120); const today = new Date(); const daysElapsed = Math.floor((today – breedingDate) / (1000 * 60 * 60 * 24)); const progressPercent = Math.min((daysElapsed / gestationDays) * 100, 100); const stage = daysElapsed <= 38 ? 'Early (Days 1–38): Embryo development, confirm pregnancy via ultrasound (day 24–35).' : daysElapsed <= 76 ? 'Mid (Days 39–76): Fetus growth, sow’s belly enlarges.' : 'Late (Days 77–114): Rapid piglet growth, nesting behavior, move to farrowing crate (day 109).'; const timeline = `
Early Stage (Days 1–38): Pregnancy confirmable via ultrasound (day 24–35).
Mid Stage (Days 39–76): Noticeable belly growth, administer vaccines (day 60).
Late Stage (Days 77–114): Sow restless, prepare farrowing crate by day 109.
`; resultDiv.innerHTML = ` Estimated Farrowing Date: ${formatDate(dueDate)}
Possible Farrowing Range: ${formatDate(minDueDate)} to ${formatDate(maxDueDate)}
Current Stage: ${daysElapsed >= 0 ? stage : ‘Pregnancy not yet started.’}
Progress:

Pregnancy Timeline: ${timeline}
Care Tips:
  • Provide balanced feed with extra protein in mid-to-late stages (day 40–100).
  • Move sow to farrowing crate by day 109 for a clean, safe delivery.
  • Monitor for no heat cycle (day 21) or restlessness; consult vet for ultrasound (day 24–35).
  • Administer vaccines (e.g., E. coli, parvovirus) around day 60 and 100.
`; resultDiv.className = ‘success’; document.getElementById(‘copy-btn’).addEventListener(‘click’, () => { const text = ` Swine Gestation Results Breeding Date: ${formatDate(breedingDate)} Gestation Period: ${gestationDays} days Estimated Farrowing Date: ${formatDate(dueDate)} Possible Farrowing Range: ${formatDate(minDueDate)} to ${formatDate(maxDueDate)} Current Stage: ${daysElapsed >= 0 ? stage : ‘Pregnancy not yet started.’} Care Tips: – Provide balanced feed with extra protein in mid-to-late stages (day 40–100). – Move sow to farrowing crate by day 109 for a clean, safe delivery. – Monitor for no heat cycle (day 21) or restlessness; consult vet for ultrasound (day 24–35). – Administer vaccines (e.g., E. coli, parvovirus) around day 60 and 100. `.trim(); navigator.clipboard.writeText(text).then(() => { alert(‘Results copied to clipboard!’); }); }); } catch (error) { resultDiv.innerHTML = `Error: ${error.message}`; resultDiv.className = ‘error’; } } function reset() { form.reset(); gestationPeriodInput.value = ‘114’; resultDiv.className = ”; resultDiv.innerHTML = ‘Enter the breeding date, then click “Calculate”.’; breedingDateInput.focus(); } document.getElementById(‘calculate-btn’).addEventListener(‘click’, calculate); document.getElementById(‘reset-btn’).addEventListener(‘click’, reset); form.addEventListener(‘keypress’, function(e) { if (e.key === ‘Enter’ && e.target.tagName !== ‘BUTTON’) { e.preventDefault(); calculate(); } }); })();