Skip to content

Commit b3e1715

Browse files
committed
add: get current timestamp utils
1 parent 0e56417 commit b3e1715

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/utils/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
// utils
1+
// utils
2+
3+
export const getCurrentTimestamp = () => {
4+
return Math.floor(Date.now() / 1000)
5+
}

tests/utils/utils.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { getCurrentTimestamp } from '@/utils';
2+
3+
describe('Utils', () => {
4+
it('Get current timestamp', () => {
5+
const timestamp = getCurrentTimestamp();
6+
const now = Math.floor(Date.now() / 1000);
7+
expect(timestamp).toBe(now);
8+
});
9+
});

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"forceConsistentCasingInFileNames": false,
2222
"noFallthroughCasesInSwitch": false,
2323
"paths": {
24-
"@/*": ["./src/*"]
24+
"@/*": ["src/*"]
2525
}
2626
},
2727
"ts-node": {

0 commit comments

Comments
 (0)