Skip to content

Commit

Permalink
add constants for millisecond amounts
Browse files Browse the repository at this point in the history
Signed-off-by: nkomonen-amazon <[email protected]>
  • Loading branch information
nkomonen-amazon committed Nov 13, 2024
1 parent 2a238d4 commit 4dddcd7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/core/src/shared/datetime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// constants for working with milliseconds
export const oneSecond = 1000
export const oneMinute = oneSecond * 60
export const oneHour = oneMinute * 60
export const oneDay = oneHour * 24
17 changes: 17 additions & 0 deletions packages/core/src/test/shared/datetime.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import assert from 'assert'
import { oneSecond, oneMinute, oneHour, oneDay } from '../../shared/datetime'

// Test that the following imports all equal the expected milliseconds
describe('millisecond constants', () => {
it('has expected milliseconds', () => {
assert.strictEqual(oneSecond, 1000)
assert.strictEqual(oneMinute, 1000 * 60)
assert.strictEqual(oneHour, 1000 * 60 * 60)
assert.strictEqual(oneDay, 1000 * 60 * 60 * 24)
})
})

0 comments on commit 4dddcd7

Please sign in to comment.