-
-
Notifications
You must be signed in to change notification settings - Fork 827
Kierangould/12hourtimestamp #903
Kierangould/12hourtimestamp #903
Conversation
Can one of the admins verify this patch? |
src/DateUtils.js
Outdated
let ampm = hours >= 12 ? 'PM' : 'AM'; | ||
hours = hours % 12; | ||
hours = hours ? hours : 12; | ||
minutes = minutes < 10 ? '0'+minutes : minutes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest just using the pad(n) function defined above :)
src/DateUtils.js
Outdated
|
||
function pad(n) { | ||
return (n < 10 ? '0' : '') + n; | ||
} | ||
|
||
function twentyfourhour(date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please indent consistently as per the code-style (i.e. 4 spaces). The function probably should be twentyFourHour()
too for consistent casing.
@@ -65,7 +65,6 @@ const SETTINGS_LABELS = [ | |||
id: 'dontSendTypingNotifications', | |||
label: "Don't send typing notifications", | |||
}, | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yay! \o/
@@ -479,24 +481,31 @@ module.exports = WithMatrixClient(React.createClass({ | |||
); | |||
|
|||
var e2e; | |||
let e2e_style; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Changing the whole CSS to make room for 24h timestamps feels a bit worrying, although I see why you're doing it...
A nicer bet here would be to just put the mx_EventTile_12h
class onto the EventTile itself, and then in the CSS have a selector like:
.mx_EventTile_12h .mx_EventTile_e2eIcon {
padding-left: 5px;
}
.mx_EventTile_12h .mx_EventTile_line {
padding-left: 100px;
}
...or whatever the tweaks are. And then you don't need all these overrides of the e2e_style, which are quite confusing at first as it makes it sound like the e2e icon is somehow very explicitly being changed by the timestamp(!) rather than just for layout purposes.
TL;DR: cascading stylesheets cascade; let's make the most of that :)
src/DateUtils.js
Outdated
import UserSettingsStore from './UserSettingsStore'; | ||
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; | ||
const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; | ||
let time; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be being blind but where is time
referenced?
src/DateUtils.js
Outdated
function twentyfourhour(date) { | ||
let hours = date.getHours(); | ||
let minutes = date.getMinutes(); | ||
let ampm = hours >= 12 ? 'PM' : 'AM'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be const
@@ -16,6 +16,8 @@ limitations under the License. | |||
|
|||
'use strict'; | |||
|
|||
import UserSettingsStore from '../../../UserSettingsStore'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be potentially be better being passed into the EventTile as a prop so it is not triggering a parse for each tile
// cosmetic padlocks: | ||
if (UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take a look at the classnames lib, would allow you to do this all in one line -ish
src/DateUtils.js
Outdated
}, | ||
|
||
formatTime: function(date) { | ||
if (UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps')) { | ||
return twentyfourhour(date); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 spaces please :)
src/DateUtils.js
Outdated
let ampm = hours >= 12 ? 'PM' : 'AM'; | ||
hours = hours % 12; | ||
hours = hours ? hours : 12; | ||
minutes = minutes < 10 ? '0'+minutes : minutes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a template literal might be more readable here or at least on the line below
tests are failing - my guess (untested) is that you need I'm also slightly having second thoughts about whether EventTile should be using a prop for this (which is set by the room itself) rather than querying the js-sdk from the depths of its render() method. If it was set by the room, then we'd have the advantage of being able to listen for |
17bd110
to
6b32975
Compare
a069cbf
to
47e5e8d
Compare
lgtm! sorry for slow review; we're drowning. |
Added support for 12 hour timestamps. Option for 12/24hr is pulled from UserSettings.