don't show time in dates long in the past
This commit is contained in:
@@ -3,15 +3,17 @@ export function shortDateFormat(then, locale) {
|
|||||||
locale = locale || window.navigator.userLanguage || window.navigator.language;
|
locale = locale || window.navigator.userLanguage || window.navigator.language;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
if (then.getFullYear() == now.getFullYear()) {
|
if (then.getFullYear() == now.getFullYear()) {
|
||||||
|
// Same year.
|
||||||
if (then.getMonth() == now.getMonth() && then.getDate() == now.getDate()) {
|
if (then.getMonth() == now.getMonth() && then.getDate() == now.getDate()) {
|
||||||
return then.toLocaleTimeString(locale, {hour12: false, hour: '2-digit', minute: '2-digit'});
|
// Same month and day, show time only.
|
||||||
} else {
|
return then.toLocaleTimeString(locale, {hour12: false, hour: '2-digit', minute: '2-digit'});
|
||||||
return then.toLocaleDateString(locale,
|
|
||||||
{hour12: false, month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'});
|
|
||||||
}
|
}
|
||||||
|
// Different month and/or day, show month day, time.
|
||||||
|
return then.toLocaleDateString(locale,
|
||||||
|
{hour12: false, month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'});
|
||||||
}
|
}
|
||||||
return then.toLocaleDateString(locale,
|
// Different year: just show the date.
|
||||||
{hour12: false, year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'});
|
return then.toLocaleDateString(locale, {year: 'numeric', month: 'short', day: 'numeric'});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert seconds to minutes:seconds, i.e. 156 sec -> 2:36.
|
// Convert seconds to minutes:seconds, i.e. 156 sec -> 2:36.
|
||||||
|
|||||||
+11
-12
@@ -499,24 +499,21 @@ function shortDateFormat(then, locale) {
|
|||||||
hour: '2-digit',
|
hour: '2-digit',
|
||||||
minute: '2-digit'
|
minute: '2-digit'
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
return then.toLocaleDateString(locale, {
|
|
||||||
hour12: false,
|
|
||||||
month: 'short',
|
|
||||||
day: 'numeric',
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return then.toLocaleDateString(locale, {
|
||||||
|
hour12: false,
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return then.toLocaleDateString(locale, {
|
return then.toLocaleDateString(locale, {
|
||||||
hour12: false,
|
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
day: 'numeric',
|
day: 'numeric'
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function secondsToTime(seconds) {
|
function secondsToTime(seconds) {
|
||||||
@@ -5204,6 +5201,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleTopicSelected(topicName) {
|
handleTopicSelected(topicName) {
|
||||||
|
console.log("handleTopicSelected", topicName);
|
||||||
|
|
||||||
if (this.state.newTopicParams && this.state.newTopicParams._topicName != topicName) {
|
if (this.state.newTopicParams && this.state.newTopicParams._topicName != topicName) {
|
||||||
this.setState({
|
this.setState({
|
||||||
newTopicParams: null
|
newTopicParams: null
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+13
-18
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user