File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { PanelType } from "../shared";
2
2
import { ToolPanel } from "../common/ToolPanel" ;
3
3
import * as vscode from "vscode" ;
4
4
import i18n from "../i18n" ;
5
+ import { isValidDate } from "../utils" ;
5
6
6
7
export class Timestamp extends ToolPanel < Timestamp > {
7
8
constructor ( panel : vscode . WebviewPanel , extensionUri : vscode . Uri ) {
@@ -19,8 +20,13 @@ export class Timestamp extends ToolPanel<Timestamp> {
19
20
20
21
public static canBeTreatedByTool ( data : string ) : boolean | PanelType {
21
22
try {
22
- new Date ( data ) ;
23
- return PanelType . timestamp ;
23
+ const d = new Date ( data ) ;
24
+ const e = new Date ( Number ( data ) ) ;
25
+ if ( isValidDate ( d ) || isValidDate ( e ) ) {
26
+ return PanelType . timestamp ;
27
+ } else {
28
+ return false ;
29
+ }
24
30
} catch ( error ) {
25
31
return false ;
26
32
}
Original file line number Diff line number Diff line change @@ -19,3 +19,7 @@ export async function asyncFilter<T>(
19
19
)
20
20
) . filter ( ( i ) => i !== fail ) ;
21
21
}
22
+
23
+ export function isValidDate ( d : Date ) : boolean {
24
+ return d instanceof Date && ! isNaN ( d . getTime ( ) ) ;
25
+ }
You can’t perform that action at this time.
0 commit comments