import options, math, times import nimhafas proc formatPoint* (point: Point): string {.exportc.} = if not point.location.isNone: let location = point.location.get if not location.name.isNone: return location.name.get else: return location.address.get else: let stop = point.stop.get return stop.name proc formatDuration* (duration: int64): string {.exportc.} = let mins = system.div(duration, 60) let h = floorDiv(mins, 60) let m = floorMod(mins, 60) if h > 0: return $h & "h " & $m & "min"; return $m & "min" proc formatTime* (timestamp: int64, mode: string): string {.exportc.} = var time = fromUnix(timestamp) if mode != "date": result = time.format("HH:mm") if now().format("ddMMYYYY") != time.format("ddMMYYYY"): result &= ", " & time.format("dd'.'MM") else: result = time.format("dd'.'MM'.'YYYY")