jasonleibowitz / react-add-to-calendar-hoc

Simple Unopinionated React Add to Calendar Button. Bring your own components.
http://leibowitz.me/react-add-to-calendar-hoc/docs/
MIT License
70 stars 40 forks source link

Bug: Yahoo's formatDuration not working correctly #39

Open JGeiser9 opened 4 years ago

JGeiser9 commented 4 years ago

Bug report

Describe the bug

The documentation states the Duration of the event should be passed as hours

However, if I want to invite someone to a quick 15 minute meeting I run into an issue where the duration calculation is misrepresented for Yahoo's minutes in the HHMM format

Assuming the following result for duration:

const startDatetime = moment(event.start.dateTime).utc(); // 2020-07-07T11:30:00-05:00 const endDatetime = moment(event.end.dateTime).utc(); // 2020-07-07T11:45:00-05:00 const duration = moment.duration(endDatetime.diff(startDatetime)).as("hours"); // 0.25

I think there should be a check in here if duration is a decimal number and convert that decimal portion to minutes. After that check proceed with the join so we would get the true minutes in the HHMM format

I wrote up a quick JSFiddle to demonstrate the current and a proposed solution - https://jsfiddle.net/sg701oqm/

Happy to open a PR as well

-Jake

System information