Skip to content

Defaulting to time.Local is a dangerous assumption #99

@brackendawson

Description

@brackendawson

ComponentBase.getTimeProp will return times in the time.Local location when time zone information is not present in the ics. This may be fine for a simple program parsing a calendar. But when a HTTP handler parses calendars on behalf of clients this will almost certainly be wrong and break time comparisons in subtle ways. Rather the client's time zone should be used, if available. Failing that it shoud be clearer that some assumption may need to be made by the developer writing the handler.

I propose adding a new constructor similar to time.ParseInLocation:

func ParseCalendarInLocation(r io.Reader, time.Location) (*Calendar, error)

The location will be stored as an unexported variable in Calendar and used for all assuptions.

ParseCalendar shall then simply return this:

func ParseCalendar(r io.Reader) (*Calendar, error) {
	return ParseCalendarInLocation(r, time.Local)
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions