This commit is contained in:
David Baker 2017-05-23 14:12:53 +01:00
parent 7d59742a22
commit 6b6fa59f3e
36 changed files with 7547 additions and 186 deletions

View file

@ -14,19 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
'use strict';
// 'use strict';
var React = require('react');
import React from 'react';
import _t from 'counterpart-riot';
import DateUtils from 'matrix-react-sdk/lib/DateUtils';
var days = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
function getdaysArray() {
var days = [];
days.push(_t('Sunday'));
days.push(_t('Monday'));
days.push(_t('Tuesday'));
days.push(_t('Wednesday'));
days.push(_t('Thursday'));
days.push(_t('Friday'));
days.push(_t('Saturday'));
return days;
}
module.exports = React.createClass({
displayName: 'DateSeparator',
@ -34,19 +38,20 @@ module.exports = React.createClass({
var date = new Date(this.props.ts);
var today = new Date();
var yesterday = new Date();
var days = getdaysArray();
yesterday.setDate(today.getDate() - 1);
var label;
if (date.toDateString() === today.toDateString()) {
label = "Today";
label = _t('Today');
}
else if (date.toDateString() === yesterday.toDateString()) {
label = "Yesterday";
label = _t('Yesterday');
}
else if (today.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
label = days[date.getDay()];
}
else {
label = date.toDateString();
label = DateUtils.formatFullDate(date);
}
return (