Fixed issue with on-hover timestamps
Этот коммит содержится в:
@@ -2,6 +2,7 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import Constants from '../utils/constants.jsx';
|
import Constants from '../utils/constants.jsx';
|
||||||
|
import * as Utils from '../utils/utils.jsx';
|
||||||
|
|
||||||
import {FormattedRelative, FormattedDate} from 'mm-intl';
|
import {FormattedRelative, FormattedDate} from 'mm-intl';
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ export default class TimeSince extends React.Component {
|
|||||||
if (this.props.sameUser) {
|
if (this.props.sameUser) {
|
||||||
return (
|
return (
|
||||||
<time className='post__time'>
|
<time className='post__time'>
|
||||||
<FormattedRelative value={this.props.eventTime} />
|
{Utils.displayTime(this.props.eventTime)}
|
||||||
</time>
|
</time>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import * as AsyncClient from './async_client.jsx';
|
|||||||
import * as client from './client.jsx';
|
import * as client from './client.jsx';
|
||||||
import Autolinker from 'autolinker';
|
import Autolinker from 'autolinker';
|
||||||
|
|
||||||
|
import {FormattedTime} from 'mm-intl';
|
||||||
|
|
||||||
export function isEmail(email) {
|
export function isEmail(email) {
|
||||||
// writing a regex to match all valid email addresses is really, really hard (see http://stackoverflow.com/a/201378)
|
// writing a regex to match all valid email addresses is really, really hard (see http://stackoverflow.com/a/201378)
|
||||||
// so we just do a simple check and rely on a verification email to tell if it's a real address
|
// so we just do a simple check and rely on a verification email to tell if it's a real address
|
||||||
@@ -209,40 +211,17 @@ export function displayDate(ticks) {
|
|||||||
return monthNames[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear();
|
return monthNames[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function displayTime(ticks, utc) {
|
export function displayTime(ticks) {
|
||||||
const d = new Date(ticks);
|
|
||||||
let hours;
|
|
||||||
let minutes;
|
|
||||||
let ampm = '';
|
|
||||||
let timezone = '';
|
|
||||||
|
|
||||||
if (utc) {
|
|
||||||
hours = d.getUTCHours();
|
|
||||||
minutes = d.getUTCMinutes();
|
|
||||||
timezone = ' UTC';
|
|
||||||
} else {
|
|
||||||
hours = d.getHours();
|
|
||||||
minutes = d.getMinutes();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minutes <= 9) {
|
|
||||||
minutes = '0' + minutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const useMilitaryTime = PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
|
const useMilitaryTime = PreferenceStore.getBool(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
|
||||||
if (!useMilitaryTime) {
|
|
||||||
ampm = ' AM';
|
|
||||||
if (hours >= 12) {
|
|
||||||
ampm = ' PM';
|
|
||||||
}
|
|
||||||
|
|
||||||
hours = hours % 12;
|
return (
|
||||||
if (!hours) {
|
<FormattedTime
|
||||||
hours = '12';
|
value={ticks}
|
||||||
}
|
hour='numeric'
|
||||||
}
|
minute='numeric'
|
||||||
|
hour12={!useMilitaryTime}
|
||||||
return hours + ':' + minutes + ampm + timezone;
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function displayDateTime(ticks) {
|
export function displayDateTime(ticks) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user