v0.2.0 ~15KB minified Apache 2.0

Peaktime
catch the perfect light

Calculate optimal start times for hiking, cycling, and trail running to catch sunrise, golden hour, or blue hour at any summit.

Loading sample route...

Core Feature

Four Estimation Models

Choose the model that matches your hiking style.

Naismith 1892

Classic rule: 5 km/h + 30 min per 300m ascent

T = D/5 + h/600
Tobler 1993

Exponential speed function based on slope

v = 6 * e^(-3.5|s + 0.05|)
Langmuir 1984

Naismith with descent adjustments

Adds time for steep descents
Munter 1980

Swiss Alpine Club method (default)

max(Th, Tv) + min(Th, Tv)/2
Accuracy

Accurate Sun Times

NOAA algorithm for sunrise, sunset, civil/nautical/astronomical twilight, golden hour, and blue hour. Accurate to within a minute.

  • Sunrise & sunset
  • Golden hour (morning & evening)
  • Blue hour (civil twilight)
  • Sun position & azimuth
Personalization

Personalized Pace

Calibrate estimates to your fitness level using 10K run time as a baseline.

Level 10K Time Factor
Leisurely 70+ min 0.75x
Moderate 55-70 min 1x
Active 45-55 min 1.25x
Athletic 38-45 min 1.56x
Fast 32-38 min 2x
Elite Under 32 min 2.5x
Conditions

Terrain Multipliers

Adjust for trail conditions.

Paved 0.9xGood trail 1xRough trail 1.25xScramble 1.5xOff-trail 1.75xSnow 1.5x
Input

GPX Support

Parse GPX files from any source with elevation data.

  • Track points & route points
  • Elevation smoothing
  • Distance & gain calculation
  • Browser & Node.js support

Use Peaktime when

  • Planning sunrise/sunset summit hikes, bike rides, or trail runs
  • Calculating hiking, cycling, or running times with multiple models
  • Building outdoor adventure apps
  • Parsing GPX files in browser or Node.js

Don't use Peaktime when

  • Real-time GPS tracking (use native APIs)
  • Complex route planning with waypoints
  • Trail difficulty ratings

Quick Start

terminal
$ npm install peaktime
app.ts
import { parseGPXOrThrow, createPlanSummary, formatStartTime } from 'peaktime';
const route = parseGPXOrThrow(gpxContent);
const plan = createPlanSummary(route, new Date('2026-06-21'), 'sunrise');
console.log(formatStartTime(plan.startTime, 'America/Los_Angeles'));
// → "4:47 AM"