Giter VIP home page Giter VIP logo

gocal's People

Contributors

apognu avatar bakerag1 avatar bootjp avatar danesparza avatar julixau avatar tatatodd avatar ukautz avatar vovanec 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gocal's Issues

RRULE with COUNT=1 .... but FREQ=WEEKLY and BYDAY=MO,TU,WE,TH,FR

Thank you so much for this library. Really addresses many issues I have with ics, and is very easy to use!

There is a bug in how COUNT is used in WEEKLY repeating events afaict, and I wanted to see what you thought.

I received an event recently that expanded by your library differently than it did in outlook & apple calendar:

RRULE:FREQ=WEEKLY;INTERVAL=1;COUNT=1;BYDAY=MO,TU,WE,TH,FR;WKST=SU

This event expanded by outlook & apple calendar to only one event on a Monday due to the COUNT argument. I don't know /why/ this ICS event got created this way... but your library expands this out to repeating monday, tuesday, wednesday, thursday, friday forever.

I'm trying to follow your logic in /rrule.go but I don't understand it very well to make a suggestion patch just yet.

VTODO support?

Do you have any plans for, or would be open to a PR for VTODO support (often surfaced as "tasks", "reminders", or "todos" in apps)?

Incorrect timezone capitalization

In parser/time.go, line 36, LoadLocation is passed the result of strings.Title(strings.ToLower()). This produces an error on Linux, where the name parameter is case sensitive (it seems to work on Macs, however). If you take the timezone "America/Los_Angeles" and run it through ToLower/Title, you end up with "America/Los_angeles", which causes LoadLocation to fail. I don't know if any processing needs to be done on the input parameter (can we assume that the capitalization will be correct on input?). If we do need to process it, then a replacement for strings.Title() should be used that also capitalizes letters after underscores.

Missing License

Hi!

I'd love to use this library in a project I'm working on, but there's no license. Would you mind adding one?

Thanks in advance,

  • mingle

Accept any date range

Another issue I'm trying to solve, the parser actually wants the date of the event before parsing the event. This is problematic as I want to load an event without knowing which date range it's in. An ugly solution would be to use a very large date range, but... well

I'm questioning the need for this parameter as mandatory. My best guess is that it's in place to prevent recurring events to become infinite, but by looking at these lines it seems not:

if gc.buffer.IsRecurring {
  rInstances = append(rInstances, gc.ExpandRecurringEvent(gc.buffer)...)
} else {
  if gc.buffer.End == nil || gc.buffer.Start == nil {
    continue
  }
  if gc.buffer.End.Before(*gc.Start) || gc.buffer.Start.After(*gc.End) {
    continue
  }

  gc.Events = append(gc.Events, *gc.buffer)
}

Before going ahead and adding a way to avoid this check in the code, I wanted to discuss this thing with you, so the library remains coherent. Are there any hazards in removing this condition (therefore making it optional)?

Thanks

Parse error when TZID contains ":"

Problem: Parsing of a DTSTART or DTEND field fails if the TZID parameter contains a : character.

Expected Behaviour: The ICS file is parsed with the field's TZID referencing the VTIMEZONE with a TZID of UTC+03:00.

Observed Behaviour: gocal error: could not parse DTSTART: 00":20220305T180000

Steps to Reproduce: Example ICS to repro below.

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:UTC+03:00
BEGIN:STANDARD
TZOFFSETFROM:+0000
TZOFFSETTO:+0300
DTSTART:19700101T000000
RRULE:FREQ=YEARLY;COUNT=1
TZNAME:UTC+03:00
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID="UTC+03:00":20220305T180000
DTEND;TZID="UTC+03:00":20220305T181500
SUMMARY:Repro
UID:Repro
DTSTAMP:20220401T194857Z
END:VEVENT
END:VCALENDAR

Document support for RRULES and X-

Hi
It seems that the project actually supports RRULES and custom attributes, it should be appropriate to put this information in the README (which is wrong if what I'm saying is true). Also it could be nice to have some bare details on how the repetition parsing works and how to get custom attributes.

Thanks

gocal can't retrieve a multiday event that borders with the end Date

For this purpose, imagine the following event, as defined in the ICS file.

BEGIN:VEVENT
DTSTART:20210430T230000Z
DTEND:20210501T170000Z
DTSTAMP:20210411T052116Z
UID:[email protected]
CREATED:20210411T041911Z
DESCRIPTION:
LAST-MODIFIED:20210411T043219Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Test Event 4
TRANSP:OPAQUE
END:VEVENT

(an event that starts on April 30th, 11PM UTC and ends on May 1st, 5PM UTC

And the following code in Go:

	startTime := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
	endTime := time.Date(year, time.Month(month+1), -1, 23, 59, 59, 999999999, time.Local)
	iCalParser.Start, iCalParser.End = &startTime, &endTime

(where year=2021, month=4)

gocal doesn't retrieve this particular event for the calendar, though it should since it started on April 30th.
I'm in UTC-5 (making the events start 5 hours early for me), so I don't think it has something to do with my locale.

If I change the code to:

	startTime := time.Date(year, time.Month(month), 1, 0, 0, 0, 0, time.Local)
	endTime := time.Date(year, time.Month(month+1), 1, 0, 0, 0, 0, time.Local)
	iCalParser.Start, iCalParser.End = &startTime, &endTime

it retrieves it correctly.

Incorrect combination of EXDATE and COUNT

Steps:
Have a recurrent event with a count and an exception date e.g.:

DTSTART:20170108T160000Z
DTEND:20170108T170000Z
RRULE:FREQ=MONTHLY;COUNT=5
EXDATE:20170408T160000Z

Expected (according to Google Calendar): COUNT should be applied before EXDATE.
E.g. result:

2017-01-08
2017-02-08
2017-03-08
2017-05-08

Actual: COUNT is applied after EXDATE:
E.g. result:

2017-01-08
2017-02-08
2017-03-08
2017-05-08
2017-06-08

Would you accept a PR to fix this?

Wrong error "could not parse duplicate RECURRENCE-ID"

Trying to parse this ics results in the error in the title. I don't find any duplicate here.

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.12.3//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
TRANSP:OPAQUE
DTEND;TZID=Europe/Rome:20160813T194500
X-APPLE-IGNORE-ON-RESTORE:TRUE
LAST-MODIFIED:20160806T202301Z
UID:7B00C665-04EB-40AA-80D5-CF40FE636A35
DTSTAMP:20160813T064448Z
LOCATION:Some location here
STATUS:CONFIRMED
SEQUENCE:0
X-APPLE-SCHEDULETAG:
X-APPLE-EWS-BUSYSTATUS:BUSY
RECURRENCE-ID;TZID=Europe/Rome:20160813T093000
SUMMARY:Work work work
DTSTART;TZID=Europe/Rome:20160813T093000
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
CREATED:20160813T064445Z
X-APPLE-ETAG:"C=8541@U=4744e3f4-75db-4a8d-a41b-9ef147659965"
BEGIN:VALARM
X-WR-ALARMUID:CC293013-456B-4BAA-851B-1F62BC6B381A
UID:CC293013-456B-4BAA-851B-1F62BC6B381A
TRIGGER;VALUE=DATE-TIME:19760401T005545Z
ACTION:NONE
END:VALARM
BEGIN:VALARM
X-WR-ALARMUID:3BC6CCD7-D2FD-406B-8960-254F18D99901
UID:3BC6CCD7-D2FD-406B-8960-254F18D99901
TRIGGER:-PT15M
ATTACH;VALUE=URI:Basso
ACTION:AUDIO
END:VALARM
END:VEVENT
END:VCALENDAR

I'm debugging it now

Recurrence ID not supported

Hi

I have calendar entries where a recurring event was moved to another date. In this case nothing is changed on the recurring event, but a new event is created with a Recurrence ID that points to the time that the event would've happened.

It seems that this case isn't picked up when parsing recurring events.

Example ical entries that shows this case:

BEGIN:VEVENT
RRULE:FREQ=WEEKLY;UNTIL=20240325T110000Z;INTERVAL=1;BYDAY=MO;WKST=SU
SUMMARY:Meeting Name
DTSTART;TZID=South Africa Standard Time:20240122T130000
DTEND;TZID=South Africa Standard Time:20240122T140000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20240219T122359Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:0
END:VEVENT

BEGIN:VEVENT
RECURRENCE-ID;TZID=South Africa Standard Time:20240219T130000
SUMMARY:Meeting Name
DTSTART;TZID=South Africa Standard Time:20240220T130000
DTEND;TZID=South Africa Standard Time:20240220T140000
CLASS:PUBLIC
PRIORITY:5
DTSTAMP:20240219T122359Z
TRANSP:OPAQUE
STATUS:CONFIRMED
SEQUENCE:11
END:VEVENT

Problem with timezones from outlook ical files

When getting a ical file from outlook I get the following start and end time:

DTSTART;TZID=Romance Standard Time:20190513T093000
DTEND;TZID=Romance Standard Time:20190513T094500

As outlook has deiceded to use windows timezones instead of standard timezones, this does not work as expected.

I would expect something like the following to parse:

func Test_ParseTimeTZID_RomanceStandardTime(t *testing.T) {
	ti, err := ParseTime("20150910T135212", map[string]string{"TZID": "Romance Standard Time"}, TimeStart)
	tz, _ := time.LoadLocation("Europe/Paris")

	assert.Equal(t, nil, err)

	assert.Equal(t, 10, ti.Day())
	assert.Equal(t, time.September, ti.Month())
	assert.Equal(t, 2015, ti.Year())
	assert.Equal(t, 13, ti.Hour())
	assert.Equal(t, 52, ti.Minute())
	assert.Equal(t, 12, ti.Second())
	assert.Equal(t, tz, ti.Location())
}

Is it possible to extend the implementation of the timezone handling to work with outlook ical files?

VALARM causes duplicate UID

I'm here again. I found that when parsing Apple Calendars (which are pretty common ics files) the library throws an error. I pinpointed the problem to a "duplicate UID" being parsed. The ICS looks like this:

BEGIN:VEVENT
TRANSP:OPAQUE
DTEND;TZID=Europe/Rome:20180816T130000
UID:EF03B2B6-7EAC-4E6E-A79E-307FDDC1B11A
DTSTAMP:20180816T120000
X-APPLE-SCHEDULETAG:
X-APPLE-SERVERFILENAME:EF03B2B6-7EAC-4E6E-A79E-307FDDC1B11A.ics
SEQUENCE:0
X-APPLE-EWS-BUSYSTATUS:BUSY
X-APPLE-TRAVEL-DURATION;VALUE=DURATION:PT15M
SUMMARY:Work work work
DTSTART;TZID=Europe/Rome:20180816T120000
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
CREATED:20180202T113551Z
X-APPLE-ETAG:"C=64865@U=4744e7f4-75db-4a8d-a41b-9ef147659965"
BEGIN:VALARM
X-WR-ALARMUID:831A361C-8CA7-4F75-8545-65D6CEA00AC2
UID:831A361C-8CA7-4F75-8545-65D6CEA00AC2
TRIGGER;X-APPLE-RELATED-TRAVEL=-PT30M:-PT45M
X-APPLE-TRAVEL-DEFAULT-ALARM:TRUE
ATTACH;VALUE=URI:Basso
ACTION:AUDIO
END:VALARM
BEGIN:VALARM
TRIGGER;VALUE=DATE-TIME:19760401T005545Z
ACTION:NONE
END:VALARM
END:VEVENT

As you can see there are two UID keys because one probably belongs to the VALARM. Even if they are not supported by the library I find a good idea to partially parse them and ignore their contents, otherwise the structure is flattened.

I'd like to help with this, but I'm relatively new to Go, and I'm using this small project as a learning exercise. If this goes well probably I will help here with the parser, which looks good already.

How to read an ICAL from a URI?

This is not an issue and the question is not strictly related to gocal but I was hoping that you may have had the issue / question before (I am starting with Go, which is quite a stretch from the Python I am used to :))

I have a URI that points to an ICAL file and was wondering if there is a clever way to parse it directly instead of going through "download the file, and then parse the downloaded file"?

My main problem is to find a matching type between what I http.Get() and what is expected by gocal.

Panic when loading this ICS file

Loading this ICS file

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ZContent.net//Zap Calendar 1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
BEGIN:VEVENT
SUMMARY:Abraham Lincoln
UID:c7614cff-3549-4a00-9152-d25cc1fe077d
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:TRANSPARENT
RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=2;BYMONTHDAY=12
DTSTART:20080212
DTEND:20080213
DTSTAMP:20150421T141403
CATEGORIES:U.S. Presidents,Civil War People
LOCATION:Hodgenville\, Kentucky
GEO:37.5739497;-85.7399606
DESCRIPTION:Born February 12\, 1809\nSixteenth President (1861-1865)\n\n\n
 \nhttp://AmericanHistoryCalendar.com
URL:http://americanhistorycalendar.com/peoplecalendar/1,328-abraham-lincol
 n
END:VEVENT
END:VCALENDAR

which was taken from
https://icalendar.org/

and inserted in the sample program

package main

import (
  "github.com/apognu/gocal"
  "os"
  "time"
  "fmt"
)

func main() {
  f, _ := os.Open("my.ics")
  defer f.Close()

  start, end := time.Now(), time.Now().Add(12*30*24*time.Hour)

  c := gocal.NewParser(f)
  c.Start, c.End = &start, &end
  c.Parse()

  for _, e := range c.Events {
    fmt.Printf("%s on %s by %s", e.Summary, e.Start,
e.Organizer.Cn)
  }
}

yields

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x4e8124]

goroutine 1 [running]:
main.main()
	/home/bert/tmp/test/goics-test.go:24 +0x304

RRULE UNTIL isn't parsed

Hi!
I've got following ics file where an event with RRULE is listed

BEGIN:VCALENDAR
X-LOTUS-CHARSET:UTF-8
VERSION:2.0
PRODID:ZMS-Berlin
BEGIN:VTIMEZONE
TZID:Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
METHOD:REQUEST
BEGIN:VEVENT
TRANSP:OPAQUE
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
CREATED:20240404T091905Z
LAST-MODIFIED:20240404T091907Z
DTSTAMP:20240404T091907Z
DTSTART;TZID="(GMT +1)":20240404T140000
DTEND;TZID="(GMT +1)":20240404T143000
SUMMARY:RRULE Test
PRIORITY:5
CLASS:PUBLIC
UID:
 040000008200E00074C5B7101A82E008000000008037F0247186DA01000000000000000001
 000000C2DE20E7AF024D739242327EEFE72B55
X-MOZ-SNOOZE-TIME:20240404T114500Z
X-MICROSOFT-CDO-OWNER-CRITICAL-CHANGE:20240404T093454Z
X-MICROSOFT-CDO-ATTENDEE-CRITICAL-CHANGE:20240404T093454Z
X-MICROSOFT-CDO-APPT-SEQUENCE:0
X-MICROSOFT-CDO-OWNERAPPTID:-1
X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
X-KOPANO-REC-PATTERN:Findet jeden Woche am Donnerstag statt\, beginnend
 am 04.04.2024 von 14:00 bis 14:30.
RRULE:FREQ=WEEKLY;UNTIL=20240404;BYDAY=MO,TH
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR

If I delete the UNTIL=20240404; part the content will be parsed as expected.
With unlimited period of validity of course.
Is there any possibility to parse the VEVENT until the intended end date?

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.