Skip to content

Commit

Permalink
rrule
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Aug 23, 2023
1 parent b5bd8f6 commit 3dc8d37
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
29 changes: 16 additions & 13 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ const event_check = function (date) {
eventStartTime === targetTime ||
(eventStartTime <= targetTime &&
eventEndTime >= targetTime &&
event.rrule_json.freq === undefined)
event.RRULE.freq === undefined)
);
});

Expand Down Expand Up @@ -842,18 +842,18 @@ let rrule_check = function (date) {
let a = new Date(events[t].dateStart).getTime();
let b = new Date(events[t].dateEnd).getTime();
let c = new Date(date).getTime();
let d = events[t].rrule_json.freq;
let d = events[t].RRULE.freq;
let e = events[t].RRULE;

if (typeof e !== "undefined" && e !== undefined && e != null) {
//recurrences

if (events[t].rrule_json != null) {
if (events[t].RRULE != null) {
//endless || with end
if (events[t].rrule_json.until == null) {
if (events[t].RRULE.until == null) {
b = new Date("3000-01-01").getTime();
} else {
b = new Date(events[t].rrule_json.until).getTime();
b = new Date(events[t].RRULE.until).getTime();
}
}

Expand Down Expand Up @@ -962,7 +962,7 @@ let event_slider = function (date) {
let a = new Date(events[i].dateStart).getTime();
let b = new Date(events[i].dateEnd).getTime();
let c = new Date(date).getTime();
let d = events[i].rrule_json.freq;
let d = events[i].RRULE.freq;

if (d === "none" || d === "" || d === undefined || d === null) {
if (a === c || (a <= c && b >= c)) {
Expand All @@ -973,8 +973,8 @@ let event_slider = function (date) {
//workaround if enddate is not set
//AKA infinity

if (events[i].rrule_json != null) {
if (events[i].rrule_json.until == null) {
if (events[i].RRULE != null) {
if (events[i].RRULE.until == null) {
b = new Date("3000-01-01").getTime();
}
}
Expand Down Expand Up @@ -2986,7 +2986,7 @@ var page_edit_event = {
"select",
{
id: "event-recur",
value: update_event_date.rrule_json.freq ?? "none",
value: update_event_date.RRULE.freq ?? "none",
class: "select-box",
},
[
Expand Down Expand Up @@ -3099,7 +3099,7 @@ let callback_getfile = function (result) {
localforage
.setItem("events", only_local_events)
.then(function () {
backup_events();
// backup_events();
side_toaster("<img src='assets/image/E25C.svg'", 2000);
setTimeout(function () {
m.route.set("/page_calendar");
Expand Down Expand Up @@ -3714,7 +3714,9 @@ const convert_ics_date = function (t, ful) {
const days = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];

const rrule_convert = function (val, date_end, date_start) {
console.log(val, date_end, date_start);
if (val === "none") {
console.log("null");
return "";
}

Expand All @@ -3725,6 +3727,7 @@ const rrule_convert = function (val, date_end, date_start) {
date_end
)}`;
}
console.log(`FREQ=${val};UNTIL=${convert_ics_date(date_end)}`);

return `FREQ=${val};UNTIL=${convert_ics_date(date_end)}`;
};
Expand Down Expand Up @@ -3911,7 +3914,7 @@ let store_event = function (db_id, cal_name) {
.setItem("events", without_subscription)
.then(function () {
clear_form();
backup_events();
// backup_events();
side_toaster("<img src='assets/image/E25C.svg'", 2000);
setTimeout(function () {
m.route.set("/page_calendar");
Expand Down Expand Up @@ -4150,7 +4153,7 @@ let update_event = function (etag, url, id, db_id, uid) {
.setItem("events", without_subscription)
.then(function () {
clear_form();
backup_events();
//backup_events();
side_toaster("<img src='assets/image/E25C.svg'", 2000);
setTimeout(function () {
m.route.set("/page_calendar");
Expand Down Expand Up @@ -4230,7 +4233,7 @@ let delete_event = function (etag, url, account_id, uid) {
localforage
.setItem("events", without_subscription)
.then(function (value) {
backup_events();
//backup_events();
side_toaster("event deleted", 2000);
if (events.length != 0) {
m.route.set("/page_events");
Expand Down
25 changes: 6 additions & 19 deletions application/assets/js/eximport.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,7 @@ export const parse_ics = async function (
let calendar_name = comp.getFirstPropertyValue("x-wr-calname") || "";

vevent.forEach(function (ite) {
let n = "";
let rr_until = "";

if (
typeof ite.getFirstPropertyValue("rrule") == "object" &&
ite.getFirstPropertyValue("rrule") != null &&
ite.getFirstPropertyValue("rrule").freq != null
) {
n = ite.getFirstPropertyValue("rrule");
if (n.until != null) {
rr_until = n.until;
}
}
let rrule = ite.getFirstPropertyValue("rrule") || "";

let dateStart, timeStart, dateStartUnix;

Expand All @@ -222,10 +210,10 @@ export const parse_ics = async function (
dateEndUnix =
new Date(ite.getFirstPropertyValue("dtend")).getTime() / 1000;

if (rr_until != "") {
dateEnd = dayjs(n.until).format("YYYY-MM-DD");
timeEnd = dayjs(n.until).format("HH:mm:ss");
dateEndUnix = new Date(n.until).getTime() / 1000;
if (rrule.until != "") {
dateEnd = dayjs(rrule.until).format("YYYY-MM-DD");
timeEnd = dayjs(rrule.until).format("HH:mm:ss");
dateEndUnix = new Date(rrule.until).getTime() / 1000;
}
}

Expand Down Expand Up @@ -266,7 +254,7 @@ export const parse_ics = async function (
LOCATION: ite.getFirstPropertyValue("location"),
DESCRIPTION: ite.getFirstPropertyValue("description"),
CATEGORIES: ite.getFirstPropertyValue("categories") || "",
RRULE: ite.getFirstPropertyValue("rrule") || "",
RRULE: rrule,
"LAST-MODIFIED": lastmod,
CLASS: ite.getFirstPropertyValue("class") || "",
DTSTAMP: dtstart,
Expand All @@ -283,7 +271,6 @@ export const parse_ics = async function (
time_start: timeStart,
time_end: timeEnd,
alarm: alarm || "none",
rrule_json: n,
etag: etag,
url: url,
calendar_name: calendar_name,
Expand Down

0 comments on commit 3dc8d37

Please sign in to comment.