duration

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package duration provides helpers for converting between flight time representations. All internal storage uses integer minutes for lossless precision.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecimalHoursToMinutes

func DecimalHoursToMinutes(hours float64) int

DecimalHoursToMinutes converts decimal hours to integer minutes via rounding.

func FormatColonHM

func FormatColonHM(minutes int) string

FormatColonHM returns a colon-separated hours:minutes string, e.g. "1:23". Suitable for EASA logbook PDF export.

func FormatDecimal

func FormatDecimal(minutes int) string

FormatDecimal returns a decimal hours string with 1 decimal place, e.g. "1.4h".

func FormatHM

func FormatHM(minutes int) string

FormatHM returns a human-readable hours:minutes string, e.g. "1h 23m".

func MinutesToDecimalHours

func MinutesToDecimalHours(minutes int) float64

MinutesToDecimalHours converts minutes to decimal hours for display/export.

func ParseDuration

func ParseDuration(input string) (int, error)

ParseDuration parses a flexible duration string into integer minutes. Accepted formats:

  • "1:23" or "01:23" → 83 minutes (colon-separated hours:minutes)
  • "1h23m" or "1h 23m" → 83 minutes
  • "1h" → 60 minutes
  • "23m" → 23 minutes
  • "83" → 83 minutes (bare integer = minutes)
  • "1.38" or "1.5" → decimal hours converted to minutes (83 or 90)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL