diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md
index d5a9f122..05d12de8 100644
--- a/modules/default/calendar/README.md
+++ b/modules/default/calendar/README.md
@@ -115,29 +115,25 @@ The following properties can be configured:
displayRepeatingCountTitle |
Show count title for yearly repeating events (e.g. "X. Birthday", "X. Anniversary")
-
Possible values: true or false
Default value: false
|
-
+
timeFormat |
- How to display the time on calendar events
-
- Possible values: relative or absolute
+ | Display event times as absolute dates, or relative time
+ Possible values: absolute or relative
Default value: relative
|
-
+
urgency |
- When .timeFormat is set to absolute , this option allows you to set a specific number of days from now to display as relative.
- For example, if urgency is set to 5 , any events happening within those 5 days will be displayed as 'in x days'.
- Any events outside of the urgency range will be displayed with an absolute date.
-
- Possible values: positive integer for example 5 (for 5 days)
- Default value: 0
+ | When using a timeFormat of absolute , the urgency setting allows you to display events within a specific time frame as relative
+ This allows events within a certain time frame to be displayed as relative (in xx days) while others are displayed as absolute dates
+ Possible values: a positive integer representing the number of days for which you want a relative date, for example 7 (for 7 days)
+ Default value: 0 (disabled)
|
-
+
diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js
index 4f65bf6a..f5c2d3f6 100644
--- a/modules/default/calendar/calendar.js
+++ b/modules/default/calendar/calendar.js
@@ -14,7 +14,7 @@ Module.register("calendar",{
maximumEntries: 10, // Total Maximum Entries
maximumNumberOfDays: 365,
displaySymbol: true,
- defaultSymbol: "calendar", // Fontawsome Symbol see http://fontawesome.io/cheatsheet/
+ defaultSymbol: "calendar", // Fontawesome Symbol see http://fontawesome.io/cheatsheet/
displayRepeatingCountTitle: false,
defaultRepeatingCountTitle: '',
maxTitleLength: 25,
@@ -141,17 +141,27 @@ Module.register("calendar",{
var timeWrapper = document.createElement("td");
//console.log(event.today);
var now = new Date();
- var one_hour = 1000 * 60 * 60;
+ // Define second, minute, hour, and day variables
+ var one_second = 1000; // 1,000 milliseconds
+ var one_minute = one_second * 60;
+ var one_hour = one_minute * 60;
var one_day = one_hour * 24;
if (event.fullDayEvent) {
if (event.today) {
timeWrapper.innerHTML = this.translate("TODAY");
- } else if (event.startDate - now < 24 * one_hour && event.startDate - now > 0) {
+ } else if (event.startDate - now < one_day && event.startDate - now > 0) {
timeWrapper.innerHTML = this.translate("TOMORROW");
} else {
+ /* Check to see if the user displays absolute or relative dates with their events
+ * Also check to see if an event is happening within an 'urgency' time frameElement
+ * For example, if the user set an .urgency of 7 days, those events that fall within that
+ * time frame will be displayed with 'in xxx' time format or moment.fromNow()
+ *
+ * Note: this needs to be put in its own function, as the whole thing repeats again verbatim
+ */
if (this.config.timeFormat === "absolute") {
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
- // This event falls within the config.urgency time frame (in days) that the user has set
+ // This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
@@ -165,16 +175,23 @@ Module.register("calendar",{
if (event.startDate - now < 2 * one_day) {
// This event is within the next 48 hours (2 days)
if (event.startDate - now < 6 * one_hour) {
- // If event is within 6 hour, display 'in xxx' time format
+ // If event is within 6 hour, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
} else {
// Otherwise just say 'Today/Tomorrow at such-n-such time'
timeWrapper.innerHTML = moment(event.startDate, "x").calendar();
}
} else {
+ /* Check to see if the user displays absolute or relative dates with their events
+ * Also check to see if an event is happening within an 'urgency' time frameElement
+ * For example, if the user set an .urgency of 7 days, those events that fall within that
+ * time frame will be displayed with 'in xxx' time format or moment.fromNow()
+ *
+ * Note: this needs to be put in its own function, as the whole thing repeats again verbatim
+ */
if (this.config.timeFormat === "absolute") {
if ((this.config.urgency > 1) && (event.startDate - now < (this.config.urgency * one_day))) {
- // This event falls within the config.urgency time frame (in days) that the user has set
+ // This event falls within the config.urgency period that the user has set
timeWrapper.innerHTML = moment(event.startDate, "x").fromNow();
} else {
timeWrapper.innerHTML = moment(event.startDate, "x").format("MMM Do");
@@ -339,3 +356,4 @@ Module.register("calendar",{
return title;
}
});
+