Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include parts in Lightning Time string #17

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ returns {
boltColor: '#01a100',
zapColor: '#3213d6',
sparkColor: '#f6853e'
},
parts: {
bolts: 0,
zaps: 1,
sparks: 3,
charges: e
}
}
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@purduehackers/time",
"version": "0.6.12",
"version": "0.6.13",
"description": "convert between traditional time and lightning time ⚡️",
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
27 changes: 13 additions & 14 deletions src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,22 @@ export class LightningTime {
const totalZaps = totalSparks / 16
const totalBolts = totalZaps / 16

const charges = Math.floor(totalCharges) % 16
const sparks = Math.floor(totalSparks) % 16
const zaps = Math.floor(totalZaps) % 16
const bolts = Math.floor(totalBolts) % 16

const lightningString =
bolts.toString(16) +
'~' +
zaps.toString(16) +
'~' +
sparks.toString(16) +
'|' +
charges.toString(16)
const charges = (Math.floor(totalCharges) % 16).toString(16)
const sparks = (Math.floor(totalSparks) % 16).toString(16)
const zaps = (Math.floor(totalZaps) % 16).toString(16)
const bolts = (Math.floor(totalBolts) % 16).toString(16)

const lightningString = bolts + '~' + zaps + '~' + sparks + '|' + charges
return {
lightningString,
strippedCharges: stripCharges(lightningString),
colors: this.getColors(lightningString)
colors: this.getColors(lightningString),
parts: {
bolts,
zaps,
sparks,
charges
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface LightningString {
lightningString: string
strippedCharges: string
colors: Colors
parts: LightningTimeParts
}

export interface LightningTimeObject {
Expand Down