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

English locale will now show a smaller version of AM/PM #5520

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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