UNPKG

@chris-lewis/fitbit-utils

Version:

Common utility modules for common tasks across projects.

21 lines (19 loc) 520 B
import { preferences } from 'user-settings'; /** * Pad a number to two digits. * * @param {number} i - Value to pad. * @returns {string} Padded number. */ export var zeroPad = function zeroPad(i) { return i >= 10 ? "".concat(i) : "0".concat(i); }; /** * Get hours according to user preference. * * @param {number} hours - Hours value. * @returns {string} Adjusted value. */ export var to24h = function to24h(hours) { return preferences.clockDisplay === '12h' ? "".concat(hours % 12 || 12) : zeroPad(hours); };