Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
fix partial events showing up on remove past events
Browse files Browse the repository at this point in the history
  • Loading branch information
ljmerza committed Dec 5, 2019
1 parent d7bacde commit 2775700
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/calendar-card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/calendar-card.js.map

Large diffs are not rendered by default.

30 changes: 16 additions & 14 deletions src/calendar-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,22 @@ export default class CalendarEvent {
* @param {boolean} isEndDate
*/
_processDate(date, isEndDate=false){
if (date) {
date = moment(date);
// add days to a start date for multi day event
if (this.addDays !== false) {
if (!isEndDate && this.addDays) date = date.add(this.addDays, 'days');

// if first day and end time then set to end of current event day that day
if (this.isFirstDay && isEndDate) {
date = moment(this.startDateTime).endOf('day');

} else if (this.isLastDay && !isEndDate) {
// if last day and start time then set start as start of day
date = date.startOf('day');
}
if (!date) return date;

date = moment(date);

// add days to a start date for multi day event
if (this.addDays !== false) {
if (!isEndDate && this.addDays) date = date.add(this.addDays, 'days');

// if not the last day and we are modifying the endDateTime then
// set end dateTimeDate as end of start day for that partial event
if (!this.isLastDay && isEndDate) {
date = moment(this.startDateTime).endOf('day');

} else if (this.isLastDay && !isEndDate) {
// if last day and start time then set start as start of day
date = date.startOf('day');
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/event.tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export function processEvents(allEvents, config) {
return events;
}, []);

// now that we have all events filter any events from config settings
// remove events before today
const today = moment().startOf('day');
newEvents = newEvents.filter(event => event.endDateTime.isAfter(today));

// if config to hide passed events then check that now
if (config.hidePastEvents) {
Expand Down

0 comments on commit 2775700

Please sign in to comment.