joniles / mpxj

Primary repository for MPXJ library

Home Page:http://www.mpxj.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RateHelper.convertToHours() wrong when source Rate is per minute

JanecekPetr opened this issue · comments

Hello!

I'm trying to use RateHelper to convert various rates to rates per hour. First of all, it would be nice if RateHelper took TimeUnitDefaultsContainer instead of a ProjectFile.

The main concern, however, lies in the math.

I'd expect

Rate onePerMinute = new Rate(1, TimeUnit.MINUTES);  // one dollar a minute
double result = RateHelper.convertToHours(null, onePerMinute);  // dollars per hour

to return 60, as in 60 dollars an hour. However, the answer is 0.0166666666.

Hi, thanks for the notes. I have updated RateHelper to provide methods which accept TimeUnitDefaultsContainer, and marked the old ProjectFile versions as deprecated. I've fixed the arithmetic error and added unit tests. Let me know if you need these changes this week and I'll get a new patch release out, otherwise it'll be mid-August before the next release.

Let me know if you need these changes this week

Thank you for such a quick turnaround! We do not need the changes quickly as it was relatively easy to work around.