[{"data":1,"prerenderedAt":464},["ShallowReactive",2],{"doc-content/docs/developer/util":3,"doc-surroundings/docs/developer/util":370,"docs-navigation":379},{"path":4,"draft":5,"date":6,"dateUpdated":7,"title":8,"body":9,"description":369,"image":6,"imageAlt":6},"/docs/developer/util",false,null,"2025-05-15","Utility Class",{"type":10,"value":11,"toc":354},"minimark",[12,16,20,38,44,51,54,85,91,94,119,125,128,152,158,161,185,191,194,227,233,244,267,273,283,289,298,304,314,320,323,329,332,338,341,347,350],[13,14,8],"h1",{"id":15},"utility-class",[17,18,19],"p",{},"All utility methods can be accessed by using:",[21,22,27],"pre",{"className":23,"code":24,"language":25,"meta":26,"style":26},"language-js shiki shiki-themes github-dark github-dark","Hologram.util\n","js","",[28,29,30],"code",{"__ignoreMap":26},[31,32,35],"span",{"class":33,"line":34},"line",1,[31,36,24],{"class":37},"suv1-",[39,40],"table-of-contents",{":bordered":41,":levels":42,"title":43},"true","[2, 3]","Util Methods",[45,46,48],"h2",{"id":47},"prettifycamelcasestring",[28,49,50],{},"prettifyCamelCase(string)",[17,52,53],{},"Converts a camel cased string into a formatted title:",[21,55,57],{"className":23,"code":56,"language":25,"meta":26,"style":26},"Hologram.util.prettifyCamelCase('myCamelCaseString')\n// Outputs: My Camel Case String\n",[28,58,59,78],{"__ignoreMap":26},[31,60,61,64,68,71,75],{"class":33,"line":34},[31,62,63],{"class":37},"Hologram.util.",[31,65,67],{"class":66},"sFR8T","prettifyCamelCase",[31,69,70],{"class":37},"(",[31,72,74],{"class":73},"s4wv1","'myCamelCaseString'",[31,76,77],{"class":37},")\n",[31,79,81],{"class":33,"line":80},2,[31,82,84],{"class":83},"sJ8bj","// Outputs: My Camel Case String\n",[45,86,88],{"id":87},"humanizesecondsseconds",[28,89,90],{},"humanizeSeconds(seconds)",[17,92,93],{},"Converts seconds to readable hours, minutes, seconds",[21,95,97],{"className":23,"code":96,"language":25,"meta":26,"style":26},"Hologram.util.humanizeSeconds(12400)\n// Outputs: 3h 26m\n",[28,98,99,114],{"__ignoreMap":26},[31,100,101,103,106,108,112],{"class":33,"line":34},[31,102,63],{"class":37},[31,104,105],{"class":66},"humanizeSeconds",[31,107,70],{"class":37},[31,109,111],{"class":110},"s8ozJ","12400",[31,113,77],{"class":37},[31,115,116],{"class":33,"line":80},[31,117,118],{"class":83},"// Outputs: 3h 26m\n",[45,120,122],{"id":121},"humanizebytesbytes-decimalplaces-0",[28,123,124],{},"humanizeBytes(bytes, decimalPlaces = 0)",[17,126,127],{},"Converts bytes to a readable format. Optionally set how many decimal places to round to.",[21,129,131],{"className":23,"code":130,"language":25,"meta":26,"style":26},"Hologram.util.humanizeBytes(10737418240)\n// Outputs: 10 GB\n",[28,132,133,147],{"__ignoreMap":26},[31,134,135,137,140,142,145],{"class":33,"line":34},[31,136,63],{"class":37},[31,138,139],{"class":66},"humanizeBytes",[31,141,70],{"class":37},[31,143,144],{"class":110},"10737418240",[31,146,77],{"class":37},[31,148,149],{"class":33,"line":80},[31,150,151],{"class":83},"// Outputs: 10 GB\n",[45,153,155],{"id":154},"formattempfahrenheit-includeunit-true",[28,156,157],{},"formatTemp(fahrenheit, includeUnit = true)",[17,159,160],{},"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.",[21,162,164],{"className":23,"code":163,"language":25,"meta":26,"style":26},"Hologram.util.formatTemp(75)\n// Outputs 75°\n",[28,165,166,180],{"__ignoreMap":26},[31,167,168,170,173,175,178],{"class":33,"line":34},[31,169,63],{"class":37},[31,171,172],{"class":66},"formatTemp",[31,174,70],{"class":37},[31,176,177],{"class":110},"75",[31,179,77],{"class":37},[31,181,182],{"class":33,"line":80},[31,183,184],{"class":83},"// Outputs 75°\n",[45,186,188],{"id":187},"formattimedateobject",[28,189,190],{},"formatTime(dateObject)",[17,192,193],{},"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.",[21,195,197],{"className":23,"code":196,"language":25,"meta":26,"style":26},"const currentTime = dayjs()\nHologram.util.formatTime(currentTime)\n",[28,198,199,217],{"__ignoreMap":26},[31,200,201,205,208,211,214],{"class":33,"line":34},[31,202,204],{"class":203},"sOPea","const",[31,206,207],{"class":110}," currentTime",[31,209,210],{"class":203}," =",[31,212,213],{"class":66}," dayjs",[31,215,216],{"class":37},"()\n",[31,218,219,221,224],{"class":33,"line":80},[31,220,63],{"class":37},[31,222,223],{"class":66},"formatTime",[31,225,226],{"class":37},"(currentTime)\n",[45,228,230],{"id":229},"formatspeedmph-includeunit-true",[28,231,232],{},"formatSpeed(mph, includeUnit = true)",[17,234,235,236,239,240,243],{},"Takes miles-per-hour as input and converts it to the user's preferred speed unit. Optional adds the corresponding ",[28,237,238],{},"mph"," of ",[28,241,242],{},"kph"," to the end.",[21,245,247],{"className":23,"code":246,"language":25,"meta":26,"style":26},"Hologram.util.formatSpeed(75)\n// Outputs 75mph\n",[28,248,249,262],{"__ignoreMap":26},[31,250,251,253,256,258,260],{"class":33,"line":34},[31,252,63],{"class":37},[31,254,255],{"class":66},"formatSpeed",[31,257,70],{"class":37},[31,259,177],{"class":110},[31,261,77],{"class":37},[31,263,264],{"class":33,"line":80},[31,265,266],{"class":83},"// Outputs 75mph\n",[45,268,270],{"id":269},"getpreferredtempunit",[28,271,272],{},"getPreferredTempUnit()",[17,274,275,276,279,280],{},"Returns the user's preferred unit of measurement for temperature: ",[28,277,278],{},"celsius"," or ",[28,281,282],{},"fahrenheit",[45,284,286],{"id":285},"getpreferredmeasurementunit",[28,287,288],{},"getPreferredMeasurementUnit()",[17,290,291,292,279,295],{},"Returns the user's preferred unit of measurement: ",[28,293,294],{},"imperial",[28,296,297],{},"metric",[45,299,301],{"id":300},"is24hourtimeenabled",[28,302,303],{},"is24HourTimeEnabled()",[17,305,306,307,309,310,313],{},"Returns ",[28,308,41],{}," if the user has enabled \"Use 24 hour time\" in Hologram's preferences. Returns ",[28,311,312],{},"false"," otherwise.",[45,315,317],{"id":316},"celsiustofahrenheitcelsius",[28,318,319],{},"celsiusToFahrenheit(celsius)",[17,321,322],{},"Converts celsius to fahrenheit",[45,324,326],{"id":325},"fahrenheittocelsiusfahrenheit",[28,327,328],{},"fahrenheitToCelsius(fahrenheit)",[17,330,331],{},"Converts fahrenheit to celsius",[45,333,335],{"id":334},"mphtokphmph",[28,336,337],{},"mphToKph(mph)",[17,339,340],{},"Converts miles per hour to kilometers per hour",[45,342,344],{"id":343},"kphtomphmph",[28,345,346],{},"kphToMph(mph)",[17,348,349],{},"Converts kilometers per hour to miles per hour",[351,352,353],"style",{},"html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .s4wv1, html code.shiki .s4wv1{--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .s8ozJ, html code.shiki .s8ozJ{--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}",{"title":26,"searchDepth":80,"depth":80,"links":355},[356,357,358,359,360,361,362,363,364,365,366,367,368],{"id":47,"depth":80,"text":50},{"id":87,"depth":80,"text":90},{"id":121,"depth":80,"text":124},{"id":154,"depth":80,"text":157},{"id":187,"depth":80,"text":190},{"id":229,"depth":80,"text":232},{"id":269,"depth":80,"text":272},{"id":285,"depth":80,"text":288},{"id":300,"depth":80,"text":303},{"id":316,"depth":80,"text":319},{"id":325,"depth":80,"text":328},{"id":334,"depth":80,"text":337},{"id":343,"depth":80,"text":346},"Utility methods available in Hologram widgets.",[371,375],{"title":372,"path":373,"stem":374,"children":-1},"Timer","/docs/developer/timer","docs/developer/12.timer",{"title":376,"path":377,"stem":378,"children":-1},"Third Party Libraries","/docs/developer/third-party","docs/developer/14.third-party",[380],{"title":381,"path":382,"stem":383,"children":384,"navigation":386},"Welcome to Hologram","/docs","docs/0.index",[385,387,391,395,399,458],{"title":381,"path":382,"stem":383,"navigation":386},true,{"title":388,"path":389,"stem":390,"navigation":386},"Themes & Wallpapers","/docs/themes","docs/1.themes",{"title":392,"path":393,"stem":394,"navigation":386},"Widgets","/docs/widgets","docs/2.widgets",{"title":396,"path":397,"stem":398,"navigation":386},"Settings","/docs/settings","docs/4.settings",{"title":400,"navigation":401,"sectionTitle":402,"collapsible":386,"path":403,"stem":404,"children":405,"page":5},"Developer",{"sectionTitle":402,"collapsible":386},"Developing Widgets","/docs/developer","docs/developer",[406,410,416,420,424,428,432,436,440,444,450,454,455,457],{"title":407,"path":408,"stem":409,"navigation":386},"Widget Developer Guide","/docs/developer/guide","docs/developer/01.guide",{"title":411,"path":412,"stem":413,"navigation":414,"sectionTitle":415},"Hologram Widget Class","/docs/developer/widget-class","docs/developer/02.widget-class",{"sectionTitle":415},"Building Widgets",{"title":417,"path":418,"stem":419,"navigation":386},"Widget Config","/docs/developer/widget-config","docs/developer/03.widget-config",{"title":421,"path":422,"stem":423,"navigation":386},"Widget Settings","/docs/developer/widget-settings","docs/developer/04.widget-settings",{"title":425,"path":426,"stem":427,"navigation":386},"Widget Color Settings","/docs/developer/widget-color-settings","docs/developer/05.widget-color-settings",{"title":429,"path":430,"stem":431,"navigation":386},"Creating Widget Presets","/docs/developer/widget-presets","docs/developer/06.widget-presets",{"title":433,"path":434,"stem":435,"navigation":386},"Making Widgets Scale","/docs/developer/making-widgets-scale","docs/developer/07.making-widgets-scale",{"title":437,"path":438,"stem":439,"navigation":386},"Simple Widget Example","/docs/developer/simple-example","docs/developer/07.simple-example",{"title":441,"path":442,"stem":443,"navigation":386},"Apple Script","/docs/developer/apple-script","docs/developer/08.apple-script",{"title":445,"path":446,"stem":447,"navigation":448,"sectionTitle":449},"Hologram API","/docs/developer/api","docs/developer/10.api",{"sectionTitle":449},"API Reference",{"title":451,"path":452,"stem":453,"navigation":386},"Weather","/docs/developer/weather","docs/developer/11.weather",{"title":372,"path":373,"stem":374,"navigation":386},{"title":8,"path":4,"stem":456,"navigation":386},"docs/developer/13.util",{"title":376,"path":377,"stem":378,"navigation":386},{"title":459,"path":460,"stem":461,"navigation":462,"sectionTitle":463},"Frequently Asked Questions","/docs/faq","docs/faq",{"sectionTitle":463},"Help",1755585913038]