This repository was archived by the owner on Apr 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed
background/methods/dataTypes
components/pages/filesytem Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -458,7 +458,7 @@ exports[`Storyshots Filesystem default 1`] = `
458
458
className = " col-md-1 col-3"
459
459
onClick = { [Function ]}
460
460
>
461
- Modified on
461
+ Last Modified
462
462
</div >
463
463
<div
464
464
className = " col-md-1 col-3"
Original file line number Diff line number Diff line change @@ -6,7 +6,42 @@ function getTimeStampFromDate(date: Date): number {
6
6
return Math . round ( new Date ( date ) . getTime ( ) / 1000 ) ;
7
7
}
8
8
9
+ function getRelativeTime ( ts : number ) : string {
10
+ const diff = Number ( new Date ( ) ) - ts * 1000 ;
11
+ const minute = 60 * 1000 ;
12
+ const hour = minute * 60 ;
13
+ /* const day = hour * 24;
14
+ const month = day * 30;
15
+ const year = day * 365;*/
16
+ switch ( true ) {
17
+ case diff < minute :
18
+ return "just now" ;
19
+ case diff < hour :
20
+ const minutes = Math . round ( diff / minute ) ;
21
+ return `${ minutes } minute${ minutes > 1 ? "s" : "" } ago` ;
22
+ /* case diff < day:
23
+ const hours = Math.round(diff / hour);
24
+ return `${hours} hour${hours > 1 ? "s" : ""} ago`;
25
+ case diff < month:
26
+ const days = Math.round(diff / day);
27
+ return `${days} day${days > 1 ? "s" : ""} ago`;
28
+ case diff < year:
29
+ const months = Math.round(diff / month);
30
+ return `${months} month${months > 1 ? "s" : ""} ago`;
31
+ case diff > year:
32
+ const years = Math.round(diff / year);
33
+ return `${years} year${years > 1 ? "s" : ""} ago`;*/
34
+ default :
35
+ return "" ;
36
+ }
37
+ }
38
+
9
39
function getDateAsStringFromTimestamp ( ts : number ) : string {
40
+ const relativeTime = getRelativeTime ( ts ) ;
41
+ if ( relativeTime ) {
42
+ return relativeTime ;
43
+ }
44
+
10
45
let dateFromTs = new Date ( ts * 1000 ) ;
11
46
let year = dateFromTs . getFullYear ( ) ;
12
47
let month = dateFromTs . getMonth ( ) + 1 ;
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ function FileListHeader(props: TReduxProps): ReactElement {
164
164
md = { fileListSize . modifiedOn . md }
165
165
onClick = { ( ) => handleSortClick ( "lastUpdated" ) }
166
166
>
167
- Modified on
167
+ Last Modified
168
168
</ Col >
169
169
{ /*Size*/ }
170
170
< Col
You can’t perform that action at this time.
0 commit comments