Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5520 from bsclifton/update-am-pm-size
Browse files Browse the repository at this point in the history
English locale will now show a smaller version of AM/PM
  • Loading branch information
cezaraugusto authored Nov 10, 2016
2 parents d0b88e1 + 7e48a2a commit 5404664
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 15 additions & 3 deletions js/about/newTabComponents/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,37 @@ class Clock extends React.Component {
constructor () {
super()
this.state = {
currentTime: this.currentTime
time: this.formattedTime,
timePeriod: this.formattedTimePeriod
}
}
get currentTime () {
const date = new Date()
const timeOptions = {hour: '2-digit', minute: '2-digit'}
return date.toLocaleTimeString([], timeOptions)
}
get formattedTime () {
const time = this.currentTime
return time.replace(' AM', '').replace(' PM', '')
}
get formattedTimePeriod () {
const time = this.currentTime
if (time.toUpperCase().indexOf(' AM') > -1) return 'AM'
if (time.toUpperCase().indexOf(' PM') > -1) return 'PM'
return ''
}
updateClock () {
this.setState({
currentTime: this.currentTime
time: this.formattedTime,
timePeriod: this.formattedTimePeriod
})
}
componentDidMount () {
window.setInterval(this.updateClock.bind(this), 1000)
}
render () {
return <div className='clock'>
<span className='time'>{this.state.currentTime}</span>
<span className='time'>{this.state.time}</span><span className='timePeriod'>{this.state.timePeriod}</span>
</div>
}
}
Expand Down
9 changes: 9 additions & 0 deletions less/about/newtab.less
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ ul {
color: #fff;
}

.timePeriod {
color: #fff;
display: inline-block;
font-size: 20px;
font-weight: 400;
margin-top: 6px;
vertical-align: top;
}

.dayTime {
font-size: 51px;
color: #fff;
Expand Down

0 comments on commit 5404664

Please sign in to comment.