Show 'tomorrow' when a full day event is planned for tomorrow.

This commit is contained in:
Michael Teeuw 2016-04-20 21:40:56 +02:00
parent fa38ad3a74
commit 64e039cf8f
2 changed files with 16 additions and 3 deletions

View File

@ -126,10 +126,16 @@ The following properties can be configured:
</tr> </tr>
<tr> <tr>
<td><code>todayText</code></td> <td><code>todayText</code></td>
<td>Text to display when an event is planned for today.<br> <td>Text to display when a fullday event is planned for today.<br>
<br><b>Default value:</b> <code>'Today'</code> <br><b>Default value:</b> <code>'Today'</code>
</td> </td>
</tr> </tr>
<tr>
<td><code>tomorrowText</code></td>
<td>Text to display when a fullday event is planned for tomorrow.<br>
<br><b>Default value:</b> <code>'Tomorrow'</code>
</td>
</tr>
<tr> <tr>
<td><code>runningText</code></td> <td><code>runningText</code></td>
<td>Text to display when an event is still running.<br> <td>Text to display when an event is still running.<br>

View File

@ -34,6 +34,7 @@ Module.register("calendar",{
// TODO: It would be nice if there is a way to get this from the Moment.js locale. // TODO: It would be nice if there is a way to get this from the Moment.js locale.
todayText: "Today", todayText: "Today",
tomorrowText: "Tomorrow",
runningText: "Ends in" runningText: "Ends in"
}, },
@ -117,11 +118,17 @@ Module.register("calendar",{
var timeWrapper = document.createElement("td"); var timeWrapper = document.createElement("td");
//console.log(event.today); //console.log(event.today);
var now = new Date();
if (event.fullDayEvent) { if (event.fullDayEvent) {
timeWrapper.innerHTML = (event.today) ? this.config.todayText : moment(event.startDate,"x").fromNow(); if (event.today) {
timeWrapper.innerHTML = this.config.todayText;
} else if (event.startDate - now < 24 * 60 * 60 * 1000) {
timeWrapper.innerHTML = this.config.tomorrowText;
} else {
timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
}
} else { } else {
if (event.startDate >= new Date()) { if (event.startDate >= new Date()) {
var now = new Date();
if (event.startDate - now > 48 * 60 * 60 * 1000) { if (event.startDate - now > 48 * 60 * 60 * 1000) {
// if the event is no longer than 2 days away, display the absolute time. // if the event is no longer than 2 days away, display the absolute time.
timeWrapper.innerHTML = moment(event.startDate,"x").fromNow(); timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();