Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Format #13

Closed
wants to merge 2 commits into from
Closed

Add Format #13

wants to merge 2 commits into from

Conversation

emersion
Copy link

Closes: #10

These will be shared between the parser and the formatter.

While at it, add a package description.
@luxifer
Copy link
Owner

luxifer commented Feb 18, 2020

Looks great! Can you try to parse an ical fixture (from the folder), then format it with your method, and re parse what you format, just to make sure the parsed fixture and the parsed format are strictly equal? this way this parser/formater will be sort of turing complete

@emersion
Copy link
Author

Unfortunately this won't work great, because a map is used to store fields, hence fields will get re-ordered. Preserving fields (and params) ordering would require adding some sort of map with a list of fields attached.

@emersion
Copy link
Author

Ah, but you mean comparing the parsed values? Yeah, can definitely do that!

@luxifer
Copy link
Owner

luxifer commented Feb 18, 2020 via email

@emersion
Copy link
Author

Hmm, so one issue is that there are two sources of truth: the Properties fields and the parsed fields (e.g. Event.Timestamp). When formatting a field, the parsed field value is currently used because it might have been updated by the user, however since some fields are redundant (Timestamp vs EndTime) the result won't be equal to the original.

I'm tempted to replace parsed fields with helper functions like net/mail.Header does.

@emersion
Copy link
Author

Ended up writing my own lib.

@emersion emersion closed this Oct 26, 2020
@emersion emersion deleted the formatter branch October 26, 2020 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an encoder
2 participants