0.1.0 • Published 3 years ago

fitbit-easy-clock v0.1.0

Weekly downloads
6
License
ISC
Repository
github
Last release
3 years ago

Fitbit Easy Clock

This package will help you build clockfaces much easier and focus on your designs

Features

  • Handle date & time updates
  • Automatic format time in 12/24 hours depending on the user preferences
  • Configurable padding with 0 for hours and minutes

Installation

Install with npm i fitbit-easy-clock or yarn add fitbit-easy-clock

Usage

import {DigitalClock, TimeData, DateData} from "fitbit-easy-clock"
import document from "document"

const timeLabel = document.getElementById('timeLabel')
const dateLabel = document.getElementById('dateLabel')

function onTimeUpdate(data: TimeData) {
  timeLabel.text = `${data.hours}:${data.minutes}`
}
function onDateUpdate(data: DateData) {
  dateLabel.text = `${data.day}/${data.month}/${data.year}`
}

new DigitalClock(onTimeUpdate, onDateUpdate, {padHours: true, padMinutes: true})

Config

interface DigitalClockConfig {
  granularity?: 'off' | 'seconds' | 'minutes' | 'hours',
  padHours?: boolean,
  padMinutes?: boolean,
  hourFormat?: '12h' | '24h' // If not set will be used the device preferences
}

Interfaces

interface TimeData {
  hours: string,
  minutes: string
}

interface DateData {
  day: number,
  month: number,
  year: number,
  weekDay: number
}