jasonleibowitz/react-add-to-calendar-hoc

Bug: Yahoo's formatDuration not working correctly

JGeiser9 opened this issue · 0 comments

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

  • OS: macOS
  • Version of Library: 1.0.10