Giter Club home page Giter Club logo

ics-golang's People

Contributors

buildscientist avatar ltho avatar ppikula avatar pulov avatar scapal avatar tobieiss avatar vanbroup avatar velppa avatar zerok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ics-golang's Issues

Failed to import Apple ics

Thanks for your great library.

I found an issue when loading apple calendar exports. the dtstart/end isn't parsed because of a tailing line feed.

Adding dt = fmt.Sprintf("%sZ", strings.TrimRight(dt, "\r\n")) to the parsing func doe fix the problem.

// parses the event start time
func (p *Parser) parseTimeField(fieldName string, eventData string) (time.Time, string) {
	reWholeDay, _ := regexp.Compile(fmt.Sprintf(`%s;VALUE=DATE:.*?\n`, fieldName))
	re, _ := regexp.Compile(fmt.Sprintf(`%s(;TZID=(.*?))?(;VALUE=DATE-TIME)?:(.*?)\n`, fieldName))
	resultWholeDay := reWholeDay.FindString(eventData)
	var t time.Time
	var tzID string

	if resultWholeDay != "" {
		// whole day event
		modified := trimField(resultWholeDay, fmt.Sprintf("%s;VALUE=DATE:", fieldName))
		t, _ = time.Parse(IcsFormatWholeDay, modified)
	} else {
		// event that has start hour and minute
		result := re.FindStringSubmatch(eventData)
		if result == nil || len(result) < 4 {
			return t, tzID
		}
		tzID = result[2]
		dt := result[4]
		if !strings.Contains(dt, "Z") {
			dt = fmt.Sprintf("%sZ", strings.TrimRight(dt, "\r\n"))
		}
		t, _ = time.Parse(IcsFormat, dt)
	}

	return t, tzID
}

Incorrect parsing of vCalendar files from Exchange

The following valid VCLANEDAR gets parsed wrongly:

BEGIN:VCALENDAR
METHOD:CANCEL
PRODID:Microsoft Exchange Server 2010
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Central Europe Standard Time
BEGIN:STANDARD
DTSTART:16010101T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN=Demo:MAILTO:[email protected]
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=Demo:
 MAILTO:[email protected]
DESCRIPTION;LANGUAGE=en-US:\n
SUMMARY;LANGUAGE=en-US:Canceled: Vacation request 1
DTSTART;VALUE=DATE:20180625
DTEND;VALUE=DATE:20180626
UID:040000008200E00074C5B7101A82E008000000006FAC5537120BD401000000000000000
 010000000B0CC569DE55F9A4CADF9A4EDE41DA534
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20180623T165005Z
TRANSP:OPAQUE
STATUS:CANCELLED
SEQUENCE:1
CATEGORIES:\\\\Seen
LOCATION;LANGUAGE=en-US:
X-MICROSOFT-CDO-APPT-SEQUENCE:1
X-MICROSOFT-CDO-OWNERAPPTID:2116467830
X-MICROSOFT-CDO-BUSYSTATUS:FREE
X-MICROSOFT-CDO-INTENDEDSTATUS:FREE
X-MICROSOFT-CDO-ALLDAYEVENT:TRUE
X-MICROSOFT-CDO-IMPORTANCE:1
X-MICROSOFT-CDO-INSTTYPE:0
X-MICROSOFT-DISALLOW-COUNTER:FALSE
END:VEVENT
END:VCALENDAR

When calling event.getSummary() an empty string is returned, although there's a specific summary in there.

I've tracked down the issue to the fact that regex seems to be used for parsing, e.g.:

func (p *Parser) parseEventSummary(eventData string) string {
	re, _ := regexp.Compile(`SUMMARY:.*?\n`)
	result := re.FindString(eventData)
	return trimField(result, "SUMMARY:")
}

As per RFC 5545 parameters are practically allowed on any vCalendar line, including SUMMARY.

Short term, this could easily be something along these lines:

func (p *Parser) parseEventSummary(eventData string) string {
	re, _ := regexp.Compile(`SUMMARY(;.*?)*:.*?\n`)
	result := re.FindString(eventData)
	return trimField(result, "SUMMARY(;.*?)*:")
}

Long term, however, some kind of parser generator would make more sense and even providing an API to get/set the additional parameters. There seems to be some for go, e.g.:

Add option to not use local files

I'd like to use this library in an environment, where I'm not allowed to write any tmp files. My application runs in a docker FROM scratch container.

It would be nice if the library supported a mode where the ics file is not saved into a local file.

Why is original UID not used?

This is just a question. Why is a new UID generated for every event? The original ID is also preserved, so I've got no problem with this. I am just curious why it was needed.

Yearly not recognized

Hi,

Thks a lot for this lib.

Yearly event are not recognized, like this :

BEGIN:VEVENT
CREATED:20151027T131802Z
LAST-MODIFIED:20151027T131834Z
DTSTAMP:20151027T131834Z
UID:d618a4c8-11a3-4793-b0da-46c824747f28
SUMMARY:Fête du Travail
RRULE:FREQ=YEARLY
CATEGORIES:Jour férié
DTSTART;VALUE=DATE:20100501
DTEND;VALUE=DATE:20100502
TRANSP:TRANSPARENT
END:VEVENT

--> GetEventsByDate gives me : "there are no events for the day 2016-05-01 00:00:00"

Active Repo?

Hello @PuloV - is this repo still active? There are 10 PR's and I was wondering if you could give someone write access to this repo to merge the PR's into.

Thanks.

Extended length summary support

The RFC does not limit the length of summary fields, although it permits implementations to truncate at 255 characters.

The following patch allows the summary to span multiple lines in the Ical file, at least to the limit of my testing.

Subject: [PATCH] allow extended length SUMMARY

---

 parse.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/parse.go b/parse.go
index 48cbfc3..0dd2634 100644
--- a/parse.go
+++ b/parse.go
@@ -431,9 +431,9 @@ func (p *Parser) parseEvents(cal *Calendar, eventsData []string) {
 
 // parses the event summary
 func (p *Parser) parseEventSummary(eventData string) string {
-	re, _ := regexp.Compile(`SUMMARY:.*?\n`)
+	re, _ := regexp.Compile(`SUMMARY:.*?\n(?:\s+.*?\n)*`)
 	result := re.FindString(eventData)
-	return trimField(result, "SUMMARY:")
+	return trimField(strings.Replace(result, "\r\n ", "", -1), "SUMMARY:")
 }
 
 // parses the event status
-- 
2.13.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.