⚡️ Lightning Time: a new way to measure time

Overview

Lightning Time ⚡️

Lightning Time ⚡️ is a new way to measure time. It's a spin on hexadecimal time: the day is split into 16 parts over and over.

The first and largest unit is called a bolt; the others are called zaps, sparks, and charges.

A typical Lightning Time string looks like 8~0~0|e, or 8~0~0 without charges.

The three major units—bolts, zaps, and sparks—are each delimited by a tilde ~. Smaller units are delimited by a single pipe |. The charge is the only named unit after the pipe, but you can go down as far as you want. For example, 8~0~0|ef4 is a valid Lightning Time string.

The super fun part: Lightning Time represents time as three colors. The respective red, green, and blue values of each color are filled in by the four time units; the rest of the values are filled in by whatever you want!

The magic of Lightning Time: represent time with not just any 3 colors, but your favorite 3 colors! 🌈

Learn more about how Lightning Time works & play with it hands-on: https://blog.purduehackers.com/posts/lightning-time


This is an npm package that allows you to use Lightning Time in your own projects.

Usage

import { LightningTime } from '@purduehackers/time'

const lt = new LightningTime()

Colors

By default, Lightning Time colors are set to the following:

bolt: (dynamic value), 161, 0
zap: 50, (dynamic value), 214
spark: 246, 133, (dynamic value)

If you want to change the static colors, you can do so by initializing a Lightning Time object like this:

const lt = new LightningTime({
  staticBoltColors: [num1, num2],
  staticZapColors: [num1, num2],
  staticSparkColors: [num1, num2]
})

Where num1 and num2 are RGB values, from 0-255.

Example:

const lt = new LightningTime({
  staticBoltColors: [120, 240],
  staticZapColors: [130, 130],
  staticSparkColors: [50, 206]
})

You don't have to set a custom value for every unit, though. Example:

const lt = new LightningTime({
  staticSparkColors: [50, 206]
})

You can also set colors after initializing a Lightning Time object like this:

lt.setStaticColors({
  staticBoltColors: [120, 240],
  staticZapColors: [130, 130],
  staticSparkColors: [50, 206]
})

Convert a Date to Lightning Time

lt.convertToLightning(new Date())

/*
Assumes it's currently 12:07 AM

returns {
  lightningString: '0~1~3|e'
  strippedCharges: '0~1~3',
  colors: {
    boltColor: '#01a100',
    zapColor: '#3213d6',
    sparkColor: '#f6853e'
  }
}
*/

Get Parts

lt.getParts('8~0~0|e')

/*
returns {
  bolts: '8',
  zaps: '0',
  sparks: '0',
  charges: 'e'
}
*/

Strip Charges

lt.stripCharges('8~0~0|e')

/*
Returns '8~0~0'
*/

Convert a Lightning Time string to a traditional time string

lt.convertFromLightning('lightning time string')

Examples:

lt.convertFromLightning('8~0~0')

/*
returns {
  withSeconds: '12:00:00 PM',
  withoutSeconds: '12:00 PM'
}
*/
lt.convertFromLightning('8~1~a|e')

/*
returns {
  withSeconds: '12:09:26 PM',
  withoutSeconds: '12:09 PM'
}
*/

Get Colors for a Lightning Time string

lt.getColors('8~0~0')

/*
Assuming `lt` was initialized with default colors
returns {
  boltColor: '#80a100',
  zapColor: '#3200d6',
  sparkColor: '#f68500'
}
*/
lt.getColors('8~1~a|e')
/*
Assuming `lt` was initialized with default colors
returns {
  boltColor: '#81a100',
  zapColor: '#321ad6',
  sparkColor: '#f685ae'
}
*/
Comments
  • Add `stripCharges()` method

    Add `stripCharges()` method

    super simple method to strip charges from a lightning time string that contains it. Intended use case:

    const noCharges = lt.convertToLightning(new Date()).stripCharges()
    
    opened by MatthewStanciu 1
  • Add `setBoltColors()` etc. methods

    Add `setBoltColors()` etc. methods

    Right now, the only way to set colors is to initialize a new object with the right colors. You should be able to set colors after initializing a new object.

    opened by MatthewStanciu 0
  • Add support for

    Add support for "counting up" e.g. timer

    Right now there's no way within this library to convert a timer to Lightning Time. There are still some unanswered questions about what a Lightning Time representation of a timer looks like though.

    opened by MatthewStanciu 0
  • Feature request: multiple built-in color combinations

    Feature request: multiple built-in color combinations

    People may not like the default colors given by purduehackers/time, but nobody wants to spend hours playing with colors to find the right combination. We should do this instead, and include 3-4 default combinations.

    Usage:

    const lt = new LightningTime({ colors: 'default' })
    // new LightningTime() with no args is still accepted
    const lt2 = new LightningTime({ colors: 'alt1' })
    // ...
    const ltx = new LightningTime({ colors: { boltColors: [0, 161], ... } })
    

    bonus: give them cute names like "ocean aurora" or some shit

    opened by MatthewStanciu 0
  • It should be possible to add more units

    It should be possible to add more units

    This is going to be very not trivial to implement, but I think there should be a way to add more units. Right now the library only goes down to charges, which means that you can't build https://lightning-time.vercel.app, which goes down one unit further, using this library. It should be possible to use this library to go down as many units as you want.

    Maybe instead of hardcoding this:

    const millisPerCharge = 1318.359375 // 86400000 / 16^4
    

    it would instead be millisPerSmallestUnit and then you could do like addUnit('unitName') and

    ugh idk how to do this rn, but should figure it out

    opened by MatthewStanciu 0
Releases(v0.5.1)
Owner
Purdue Hackers
A community of students who collaborate, learn, and build kick-ass technical projects 💛⚡️
Purdue Hackers
Habitapp is a simple app that helps you build positive habits, measure progress and achieve your goals

habitapp Habitapp is a simple app that helps you build positive habits, measure progress and achieve your goals. ✨ Features Working without registrati

null 6 Sep 11, 2022
Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers

Lightning Web Chart.js Component Simple yet flexible charting Lightning Web Component using Chart.js for admins & developers Documentation Getting sta

@SalesforceLabs 109 Dec 9, 2022
A website for tracking community support for BIP21 QR codes that support on-chain and lightning bitcoin payments.

BIP21 Microsite This is a WIP microsite to promote the usage of a BIP21 payment URI QR code that can include lightning invoices or offers. Wallet supp

Stephen DeLorme 16 Nov 27, 2022
Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Inter Process Communication Module for node supporting Unix sockets, TCP, TLS, and UDP. Giving lightning speed on Linux, Mac, and Windows. Neural Networking in Node.JS

Node IPC 43 Dec 9, 2022
🦆 lightning fast duckdb bindings for bun runtime

@evan/duckdb lightning fast duckdb bindings for bun runtime Install bun add @evan/duckdb Features ?? batteries included ?? jit optimized bindings ?? 4

evan 29 Oct 20, 2022
Web app that generates BOLT11 invoices from an LNURL or Lightning Address.

LNURL Pay ⚡️ Web app that generates BOLT11 invoices from an LNURL or Lightning Address. Getting Started First, run the development server: npm run dev

Sam Samskies 7 Nov 3, 2022
ln-charts parses the output of bos accounting commands into various charts for your Lightning Node.

ln-charts ln-charts parses the output of bos accounting commands into various charts for your Lightning Node. It runs on Angular, JS, HTML, CSS, ngx-c

Steven Ellis 21 Dec 18, 2022
A tiny, lightning fast jQuery-like library for modern browsers.

Sprint.js Sprint is a high-performance, 5KB (gzipped) DOM library for modern browsers. Sprint notably shines on bandwidth and resource constrained dev

Benjamin De Cock 4.3k Jan 3, 2023
A boilerplate project to build proof of concept paywalls with lightning service authentication tokens (LSATs)

lsat-workshop-boilerplate A boilerplate project to build proof of concept paywalls with lightning service authentication tokens (LSATs) Install Setup

Buck Perley 2 Oct 13, 2022
Catalogist is the easy way to catalog and make your software and (micro)services visible to your organization in a lightweight and developer-friendly way.

catalogist ?? ?? ?? ?? ?? The easy way to catalog and make your software and (micro)services visible to your organization through an API You were a pe

Mikael Vesavuori 11 Dec 13, 2022
🎨 Beautify your github profile with this amazing tool, creating the readme your way in a simple and fast way 🚀 The best profile readme generator you will find ⚡

Demo Profile Readme Generator The best profile readme generator you will find! About | Technologies | Requirements | Starting | Contributing ?? About

Mauro de Souza 476 Jan 1, 2023
A quick way of bootstrapping a new mono-repo for a Web Application

marp theme class author true gaia lead invert Matteo ronchi [email protected] Mono-repo Starter https://github.com/cef62/monorepo-template What

Matteo Ronchi 12 Jul 29, 2022
A new way to share your readings with friends. Hope you like it!

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Gardenia Georgia 4 Sep 9, 2022
MySQL meets Jupyter notebooks. Grasp provides a new way to learn and write SQL, by providing a coding-notebook style with runnable blocks, markdown documentation, and shareable notebooks. ✨

A New Way to Write & Learn SQL Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Prerequisites Installation

Lakshya 7 Sep 1, 2022
🔒 The new way to do types in typescript.

Nominal The right way to do types in typescript. Installation npm install nominal-types yarn install nominal-types pnpm install nominal-types Usage

Modfy 251 Dec 24, 2022
Quick way to start a new TypeScript/Next.js/Firebase web app 😼

create-crash-app Template repo to quickly set up an opinionated, strict config, typesafe Next.js project. Get started with create-crash-app by running

Diego Dorantes-Ferreira 5 Oct 28, 2022
Easily open daily notes and periodic notes in new pane; customize periodic notes background; quick append new line to daily notes.

Obsidian daily notes opener This plugin adds a command for opening daily notes in a new pane (so that a keyboard shortcut could be used!) and gives ex

Xiao Meng 16 Dec 26, 2022
:new:A new version of Icalingua.

Icalingua 3 新版 Icalingua。将抛弃 Electron,转向网页前端 + Node 后端(类似于原来 icalingua-bridge-oicq)的模式。 正在开发中。当前技术栈选型: oicq2 socket.io Vue3 Fastify WindiCSS rxjs Mikr

Icalingua++ 150 Dec 27, 2022
Logs the output, time, arguments, and stacktrace of any function when it's called in a gorgeous way.

Function.prototype.log Logs the output, time, arguments, and stacktrace of any function when it's called. How to use: Like this: function yourFunction

--Explosion-- 4 Apr 9, 2022