Utility Class

All utility methods can be accessed by using:

    Hologram.util

prettifyCamelCase(string)

Converts a camel cased string into a formatted title:

Hologram.util.prettifyCamelCase('myCamelCaseString')
// Outputs: My Camel Case String

humanizeSeconds(seconds)

Converts seconds to readable hours, minutes, seconds

Hologram.util.humanizeSeconds(12400)
// Outputs: 3h 26m

humanizeBytes(bytes, decimalPlaces = 0)

Converts bytes to a readable format. Optionally set how many deicmal places to round to.

Hologram.util.humanizeBytes(10737418240)
// Outputs: 10 GB

formatTemp(fahrenheit, includeUnit = true)

Takes a temperature in fahrenheit as input, and converts it to the users preferred unit. Optionally adds the degree symbol (°) if include includeUnit is true.

Hologram.util.formatTemp(75)
// Outputs 75°

formatTime(dateObject)

Takes a date object as input and formats it to either 12 hour or 24 hour time, based on whether the user has the "use 24 time" checkbox selected in Hologram's preferences panel.

let currentTime = dayjs()
Hologram.util.formatTime(currentTime)

formatSpeed(mph, includeUnit = true)

Takes miles-per-hour as input and converts it to the user's preferred speed unit. Optional adds the corresponding mph of kph to the end.

Hologram.util.formatSpeed(75)
// Outputs 75mph

getPreferredTempUnit()

Returns the user's preferred unit of measurement for temperature: celsius or fahrenheit


getPreferredMeasurementUnit()

Returns the user's preferred unit of measurement: imperial or metric


is24HourTimeEnabled()

Returns true if the user has enabled "Use 24 hour time" in Hologram's preferences. Returns false otherwise.


celsiusToFahrenheit(celsius)

Converts celsius to fahrenheit


fahrenheitToCelsius(fahrenheit)

Converts fahrenheit to celsius


mphToKph(mph)

Converts miles per hour to kilometers per hour


kphToMph(mph)

Converts kilometers per hour to miles per hour