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

Commit

Permalink
English locale will now show a smaller version of AM/PM
Browse files Browse the repository at this point in the history
Fixes #5381

Auditors: @cezaraugusto

Test Plan:
1. Set your locale in Preferences to be English (U.S.)
2. Visit about:newtab; AM/PM (if shown for you) should be smaller than the font-size used for the hour/minute
  • Loading branch information
bsclifton committed Nov 9, 2016
1 parent 34dc85e commit 7e48a2a
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 7e48a2a

Please sign in to comment.