src/components/CV/Block/ItemTime.js   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 35
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
mnd 1
bc 1
fnc 0
dl 0
loc 35
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from 'react'
2
import PropTypes from 'prop-types'
3
import { withTranslation } from 'react-i18next'
4
import { connect } from 'react-redux'
5
import { autoDetectDmy } from 'Src/utils/timeFormat'
6
import tbbStyle from './TimeBasedBlock.scss'
7
8
const ItemTime = ({ from, to, currentLang, t }) => {
9
  const fromLocale = autoDetectDmy(from, currentLang)
10
  const toLocale = autoDetectDmy(to, currentLang)
11
  return (
12
    <div className={tbbStyle.time}>
13
      {to
14
        ? t('{{from}} – {{to}}', {
15
            from: fromLocale,
16
            to: toLocale,
17
          })
18
        : t('{{from}} – now', { from: fromLocale })}
19
    </div>
20
  )
21
}
22
23
ItemTime.propTypes = {
24
  from: PropTypes.string.isRequired,
25
  to: PropTypes.string,
26
  currentLang: PropTypes.string.isRequired,
27
  t: PropTypes.func.isRequired,
28
}
29
30
const mapStateToProps = (state) => ({
31
  currentLang: state.lang,
32
})
33
34
export default connect(mapStateToProps)(withTranslation()(ItemTime))
35