File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ * Contains an assortment of helper constants and functions for working with dates.
3+ */
4+
5+ const dateWithoutYearFormatter = new Intl . DateTimeFormat ( 'en' , {
6+ month : 'short' ,
7+ day : 'numeric' ,
8+ hour : 'numeric' ,
9+ minute : '2-digit' ,
10+ } ) ;
11+
12+ const dateFormatter = new Intl . DateTimeFormat ( 'en' , {
13+ year : 'numeric' ,
14+ month : 'short' ,
15+ day : 'numeric' ,
16+ hour : 'numeric' ,
17+ minute : '2-digit' ,
18+ } ) ;
19+
20+ export function formatDate ( value : Date ) : string {
21+ if ( value . getFullYear ( ) === new Date ( ) . getFullYear ( ) ) {
22+ return dateWithoutYearFormatter . format ( value ) ;
23+ }
24+
25+ return dateFormatter . format ( value ) ;
26+ }
Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import styled from 'styled-components' ;
33import { VSCodeLink } from '@vscode/webview-ui-toolkit/react' ;
4+ import { formatDate } from '../../pure/date' ;
45
56type Props = {
67 completedAt ?: Date | undefined ;
78
89 onViewLogsClick : ( ) => void ;
910} ;
1011
12+ const Container = styled . div `
13+ display: flex;
14+ flex-direction: column;
15+ gap: 0.5em;
16+ ` ;
17+
1118const Icon = styled . span `
1219 font-size: 1em !important;
1320 vertical-align: text-bottom;
1421` ;
1522
16- const ViewLogsLink = styled ( VSCodeLink ) `
17- margin-top: 0.2em;
18- ` ;
19-
2023export const VariantAnalysisCompletionStats = ( {
2124 completedAt,
2225 onViewLogsClick,
@@ -26,9 +29,9 @@ export const VariantAnalysisCompletionStats = ({
2629 }
2730
2831 return (
29- < >
30- { completedAt . toLocaleString ( ) }
31- < ViewLogsLink onClick = { onViewLogsClick } > View logs</ ViewLogsLink >
32- </ >
32+ < Container >
33+ < span > { formatDate ( completedAt ) } </ span >
34+ < VSCodeLink onClick = { onViewLogsClick } > View logs</ VSCodeLink >
35+ </ Container >
3336 ) ;
3437} ;
You can’t perform that action at this time.
0 commit comments