Skip to content

Commit

Permalink
Merge pull request #17 from purduehackers/include-parts-in-lt-string
Browse files Browse the repository at this point in the history
Include parts in Lightning Time string
  • Loading branch information
MatthewStanciu authored Dec 11, 2023
2 parents 5cad6f1 + 0d2d8fa commit c9b4a31
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
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

0 comments on commit c9b4a31

Please sign in to comment.