mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge pull request #1439 from esteemapp/rev
revert getTimeFromNow to moment usage until Intl support is added int…
This commit is contained in:
commit
454fc6b38a
Binary file not shown.
@ -32,17 +32,7 @@ const UserListItem = ({
|
||||
<UserAvatar noAction={userCanPress} style={styles.avatar} username={username} />
|
||||
<View style={styles.userDescription}>
|
||||
<Text style={styles.name}>{text || username}</Text>
|
||||
{description && (
|
||||
<Text style={styles.date}>
|
||||
<FormattedRelativeTime
|
||||
value={description.value}
|
||||
numeric="auto"
|
||||
// eslint-disable-next-line react/style-prop-object
|
||||
style="short"
|
||||
unit={description.unit}
|
||||
/>
|
||||
</Text>
|
||||
)}
|
||||
{description && <Text style={styles.date}>{description}</Text>}
|
||||
</View>
|
||||
{middleText && (
|
||||
<View style={styles.middleWrapper}>
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { View, Text, TouchableOpacity } from 'react-native';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
import { injectIntl, FormattedRelativeTime } from 'react-intl';
|
||||
import { injectIntl } from 'react-intl';
|
||||
|
||||
// Components
|
||||
import { Tag } from '../../../basicUIElements';
|
||||
@ -78,17 +78,7 @@ class PostHeaderDescription extends PureComponent {
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
<Text style={styles.date}>
|
||||
{isPromoted ? (
|
||||
intl.formatMessage({ id: 'post.sponsored' })
|
||||
) : (
|
||||
<FormattedRelativeTime
|
||||
value={date.value}
|
||||
// eslint-disable-next-line react/style-prop-object
|
||||
style="short"
|
||||
numeric="auto"
|
||||
unit={date.unit}
|
||||
/>
|
||||
)}
|
||||
{isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date}
|
||||
</Text>
|
||||
{isShowOwnerIndicator && (
|
||||
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
|
||||
|
@ -45,6 +45,7 @@ class PostListItemView extends Component {
|
||||
handleOnRemoveItem,
|
||||
id,
|
||||
intl,
|
||||
isFormatedDate,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -52,7 +53,7 @@ class PostListItemView extends Component {
|
||||
<View style={styles.container}>
|
||||
<View style={styles.header}>
|
||||
<PostHeaderDescription
|
||||
date={getTimeFromNow(created)}
|
||||
date={isFormatedDate ? created : getTimeFromNow(created, true)}
|
||||
name={username}
|
||||
reputation={reputation}
|
||||
size={36}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import { View, TouchableOpacity, Text, Alert } from 'react-native';
|
||||
import { injectIntl, FormattedRelativeTime } from 'react-intl';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { Popover, PopoverController } from 'react-native-modal-popover';
|
||||
import Slider from 'react-native-slider';
|
||||
import get from 'lodash/get';
|
||||
@ -331,14 +331,7 @@ class UpvoteView extends Component {
|
||||
<Text style={styles.detailsText}>
|
||||
{`${intl.formatMessage({
|
||||
id: 'payout.payout_date',
|
||||
})} `}
|
||||
<FormattedRelativeTime
|
||||
value={payoutDate.value}
|
||||
numeric="auto"
|
||||
// eslint-disable-next-line react/style-prop-object
|
||||
style="short"
|
||||
unit={payoutDate.unit}
|
||||
/>
|
||||
})} ${payoutDate}`}
|
||||
</Text>
|
||||
{warnZeroPayout && (
|
||||
<Text style={styles.detailsText}>
|
||||
|
@ -1,3 +1,5 @@
|
||||
import moment from 'moment';
|
||||
|
||||
const TODAY = new Date();
|
||||
const ONE_DAY = new Date(TODAY.getTime() - 24 * 60 * 60 * 1000);
|
||||
const SEVEN_DAY = new Date(TODAY.getTime() - 7 * 24 * 60 * 60 * 1000);
|
||||
@ -9,7 +11,8 @@ const WEEK = 60 * 60 * 24 * 7;
|
||||
const MONTH = 60 * 60 * 24 * 30;
|
||||
const YEAR = 60 * 60 * 24 * 365;
|
||||
|
||||
export const getTimeFromNow = d => {
|
||||
// TODO: once hermes has Intl support, enable native version
|
||||
export const getTimeFromNowNative = d => {
|
||||
if (!d) {
|
||||
return null;
|
||||
}
|
||||
@ -49,6 +52,17 @@ export const getTimeFromNow = d => {
|
||||
}
|
||||
return { unit: 'day', value: future ? Math.round(diff / DAY) : -Math.round(diff / DAY) };
|
||||
};
|
||||
export const getTimeFromNow = (value, isWithoutUtc) => {
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isWithoutUtc) {
|
||||
return moment(value).fromNow(true);
|
||||
}
|
||||
|
||||
return moment.utc(value).fromNow(true);
|
||||
};
|
||||
|
||||
export const getFormatedCreatedDate = value => {
|
||||
if (!value) {
|
||||
|
Loading…
Reference in New Issue
Block a user