From a31bfa6686eb52506d600a5b77a96fddeb9fb344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 3 Oct 2021 00:47:50 +0200 Subject: to_jcal for new VEvent class. --- static/globals.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'static') diff --git a/static/globals.js b/static/globals.js index fd576e26..c414fc5b 100644 --- a/static/globals.js +++ b/static/globals.js @@ -6,6 +6,44 @@ class VEventValue { this.value = value; this.parameters = parameters; } + + to_jcal () { + let value; + let v = this.value; + switch (this.type) { + case 'binary': + /* TOOD */ + break; + case 'date-time': + value = v.format("~Y-~m-~dT~H:~M:~S"); + // TODO TZ + break; + case 'date': + value = v.format("~Y-~m-~d"); + break; + case 'duration': + /* TODO */ + break; + case 'period': + /* TODO */ + break; + case 'utc-offset': + /* TODO */ + break; + case 'recur': + value = v.asJcal(); + break; + + case 'float': + case 'integer': + case 'text': + case 'uri': + case 'cal-address': + case 'boolean': + value = v; + } + return [this.parameters, this.type, value]; + } } /* maybe ... */ @@ -43,6 +81,16 @@ class VEvent { register (htmlNode) { this.registered.push(htmlNode); } + + to_jcal () { + let out_properties = [] + for (let [key, value] of Object.entries(this.properties)) { + let sub = value.to_jcal(); + sub.unshift(key) + out_properties.push(sub); + } + return ['vevent', out_properties, [/* alarms go here*/]] + } } function make_vevent_value (value_tag) { -- cgit v1.2.3