Skip to content

Commit

Permalink
Add colors to convertToLightning()
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewStanciu committed Oct 16, 2022
1 parent e77aba1 commit 271e60e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ Assumes it's currently 12:07 AM
returns {
lightningString: '0~1~3|e'
strippedCharges: '0~1~3'
strippedCharges: '0~1~3',
colors: {
boltColor: '#01a100',
zapColor: '#3213d6',
sparkColor: '#f6853e'
}
}
*/
```
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.3.12",
"version": "0.4.0",
"description": "convert between traditional time and lightning time ⚡️",
"main": "dist/index.js",
"module": "dist/esm/index.js",
Expand Down
3 changes: 2 additions & 1 deletion src/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export class LightningTime {
charges.toString(16)
return {
lightningString,
strippedCharges: stripCharges(lightningString)
strippedCharges: stripCharges(lightningString),
colors: this.getColors(lightningString)
}
}

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

export interface LightningTimeObject {
Expand Down
13 changes: 13 additions & 0 deletions test/LightningTime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ describe('to lightning', () => {
const convert = lightningTime.convertToLightning(time)
expect(convert.strippedCharges).toEqual('8~0~0')
})
it('should convert to lightning and get colors', () => {
const time = new Date()
time.setHours(12)
time.setMinutes(0)
time.setSeconds(0)
const lightningTime = new LightningTime()
const convert = lightningTime.convertToLightning(time)
expect(convert.colors).toMatchObject({
boltColor: '80a100',
zapColor: '3200d6',
sparkColor: 'f68500'
})
})
})

describe('strip charges', () => {
Expand Down

0 comments on commit 271e60e

Please sign in to comment.