File tree 2 files changed +28
-6
lines changed 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1
1
export { fetchDummyData } from './fetchDummyData' ;
2
- export {
3
- validateType ,
4
- fontSize ,
5
- placeHolder ,
6
- listComponent ,
7
- } from './blockContent' ;
2
+ export * from './blockContent' ;
8
3
export * from './debounce' ;
9
4
export * from './fetchApi' ;
10
5
export * from './blockApis' ;
11
6
export * from './pageApis' ;
7
+ export * from './time' ;
Original file line number Diff line number Diff line change
1
+ export const timeSince = ( date : Date ) => {
2
+ const seconds = Math . floor ( ( + new Date ( ) - + date ) / 1000 ) ;
3
+
4
+ let interval = seconds / 31536000 ;
5
+
6
+ if ( interval > 1 ) {
7
+ return `${ Math . floor ( interval ) } years` ;
8
+ }
9
+ interval = seconds / 2592000 ;
10
+ if ( interval > 1 ) {
11
+ return `${ Math . floor ( interval ) } months` ;
12
+ }
13
+ interval = seconds / 86400 ;
14
+ if ( interval > 1 ) {
15
+ return `${ Math . floor ( interval ) } days` ;
16
+ }
17
+ interval = seconds / 3600 ;
18
+ if ( interval > 1 ) {
19
+ return `${ Math . floor ( interval ) } hours` ;
20
+ }
21
+ interval = seconds / 60 ;
22
+ if ( interval > 1 ) {
23
+ return `${ Math . floor ( interval ) } minutes` ;
24
+ }
25
+ return `${ Math . floor ( seconds ) } seconds` ;
26
+ } ;
You can’t perform that action at this time.
0 commit comments