Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

0 Duration gets formatted to 'P' #33

Open
andresmatasuarez opened this issue Mar 20, 2015 · 1 comment
Open

0 Duration gets formatted to 'P' #33

andresmatasuarez opened this issue Mar 20, 2015 · 1 comment

Comments

@andresmatasuarez
Copy link
Contributor

Got across this issue when trying to set a VALARM with a trigger at the time of the event (in other words, with a zero duration).

When I printed the resulting calendar, I noticed that TRIGGER property was 'P', instead of 'P0D'.

I have been looking at the code and it's not a difficult issue to tackle. However, I have seen that you are currently making all the calculations manually, have you taken a look at the awesome MomentJS library?

From http://momentjs.com/docs/#/durations/as-json/:
"When serializing a duration object to JSON, it will be be represented as an ISO8601 string."

If I am making no mistakes, at least DURATION.format method from lib/types can be replaced with moment.duration(value, 'seconds').toJSON()

_UPDATE_
From iCalendar RFC 5545:
"Note that unlike [ISO.8601.2004], this value type doesn't support the "Y" and "M" designators to specify durations in terms of years and months."

Taking into account that moment.duration.toJSON strictly follows ISO8601, then no, MomentJS its not a DIRECT replacement for this method. However, moment.duration object (and the MomentJS library in general) can still reduce A LOT of code.

@inopinatus
Copy link

Confirming that my TRIGGER of "-P0DT1H30M0S" is being similarly mangled to a single P.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants