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

0 Duration gets formatted to 'P' #33

@andresmatasuarez

Description

@andresmatasuarez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions