Skip to content

๐ŸŽ Elixir module to calculate the delta between two laptimes

License

Notifications You must be signed in to change notification settings

pr0grammr/hotlap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

33 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Hotlap

Calculates the delta of 2 laptimes

build & test Hex.pm Hex.pm

Installation

The package can be installed by adding hotlap to your list of dependencies in mix.exs:

def deps do
  [
    {:hotlap, "~> 1.0.0"}
  ]
end

Usage

# create laptime struct
laptime = %Hotlap.Laptime{minutes: 1, seconds: 22, milliseconds: 455}
# => %Hotlap.Laptime{minutes: 1, seconds: 22, milliseconds: 455}

# create from string
{:ok, laptime} = Hotlap.Laptime.create("01:22.455")
# => %Hotlap.Laptime{minutes: 1, seconds: 22, milliseconds: 455}

# convert to milliseconds
laptime_milliseconds = Hotlap.LaptimeConverter.to_milliseconds(laptime)
# => 82455


# compare two laptimes
{:ok, target_laptime} = Hotlap.Laptime.create("01:22.455")
{:ok, current_laptime} = Hotlap.Laptime.create("01:22.899")
delta = Hotlap.compare(target_laptime, current_laptime)
# => %Hotlap.Delta{minutes: 0, seconds: 0, milliseconds: 455, status: :behind}

# string representation
IO.puts "Target: #{target_laptime}" # => 01:22.455
IO.puts "Current: #{current_laptime}" # => 01:22.899
IO.puts "Delta: #{delta}" # => +0.444

License

This module is published under the MIT license

About

๐ŸŽ Elixir module to calculate the delta between two laptimes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages