11import React , { Component } from 'react' ;
2- import i18n from 'I18nSetup' ;
32import { withTranslation } from 'react-i18next' ;
43import PropTypes from 'prop-types' ;
4+ import 'I18nSetup' ;
55
66/**
77 * CandidateInfo is a React component which is used for the
@@ -37,9 +37,15 @@ class CandidateInfo extends Component {
3737 const months = years * 12 + now . getMonth ( ) - dobdate . getMonth ( ) ;
3838
3939 if ( months <= 36 ) {
40- return this . props . t ( '{{months}} months old' , { ns : 'loris' , months : months } ) ;
40+ return this . props . t (
41+ '{{months}} months old' ,
42+ { ns : 'loris' , months : months }
43+ ) ;
4144 }
42- return this . props . t ( '{{years}} years old' , { ns : 'loris' , years : years } ) ;
45+ return this . props . t (
46+ '{{years}} years old' ,
47+ { ns : 'loris' , years : years }
48+ ) ;
4349 }
4450
4551 /**
@@ -107,6 +113,14 @@ class CandidateInfo extends Component {
107113 */
108114 render ( ) {
109115 const cohorts = this . getCohorts ( this . props . Visits ) ;
116+ const dateFormatter = new Intl . DateTimeFormat (
117+ loris . user . langpref . replace ( '_' , '-' ) ,
118+ {
119+ style : 'short' ,
120+ timeZone : 'UTC' ,
121+
122+ }
123+ ) ;
110124
111125 const data = [
112126 {
@@ -119,7 +133,7 @@ class CandidateInfo extends Component {
119133 } ,
120134 {
121135 label : this . props . t ( 'Date of Birth' , { ns : 'loris' } ) ,
122- value : this . props . Candidate . Meta . DoB ,
136+ value : dateFormatter . format ( new Date ( this . props . Candidate . Meta . DoB ) ) ,
123137 valueWhitespace : 'nowrap' ,
124138 } ,
125139 {
@@ -210,6 +224,11 @@ CandidateInfo.propTypes = {
210224 Visits : PropTypes . array . isRequired ,
211225 VisitMap : PropTypes . object . isRequired ,
212226 ExtraCandidateInfo : PropTypes . array ,
227+
228+ // Provided by withTranslation HOC
229+ t : PropTypes . func ,
213230} ;
214231
215- export default { CandidateInfo : withTranslation ( [ 'candidate_profile' , 'loris' ] ) ( CandidateInfo ) } ;
232+ export default {
233+ CandidateInfo : withTranslation ( [ 'candidate_profile' , 'loris' ] ) ( CandidateInfo ) ,
234+ } ;
0 commit comments